svnno****@sourc*****
svnno****@sourc*****
2009年 5月 27日 (水) 23:08:25 JST
Revision: 1188 http://svn.sourceforge.jp/view?root=sie&view=rev&rev=1188 Author: dhrname Date: 2009-05-27 23:08:25 +0900 (Wed, 27 May 2009) Log Message: ----------- Matrixオブジェクトの代わりに、2次元配列を用いて高速化 Modified Paths: -------------- branches/05x/050/sie.js Modified: branches/05x/050/sie.js =================================================================== --- branches/05x/050/sie.js 2009-05-26 11:22:30 UTC (rev 1187) +++ branches/05x/050/sie.js 2009-05-27 14:08:25 UTC (rev 1188) @@ -54,7 +54,7 @@ //IEだったらtrueを返す var isMSIE = /*@cc_on!@*/false; //引数にtrueがあれば、例外処理のログを作動させる - stlog = new STLog(false); + stlog = new STLog(true); var ary = document.getElementsByTagName("script"); for (var i=0; i < ary.length; i++) {//全script要素をチェックして、type属性がimage/svg+xmlならば、中身をSVGとして処理する var hoge = ary[i].type; @@ -558,7 +558,7 @@ var x = 0, y = 0; //現在の点の絶対座標 var x0 = 0, y0 = 0; //subpath の始点の絶対座標 var dx = 0, dy = 0; - var tma = ttm.a, tmb = ttm.b, tmc = ttm.c, tmd = ttm.d, tme = ttm.e, tmf = ttm.f; + var tma = ttm[0][0], tmb = ttm[1][0], tmc = ttm[0][1], tmd = ttm[1][1], tme = ttm[0][2], tmf = ttm[1][2]; for (var i = 0, Dli = D.length; i < Dli; ++i) { var F = D[i]; var com = F[0].toLowerCase(); //F[0]の値はコマンド文字 @@ -875,14 +875,14 @@ var ptt = pt.matrixTransform(ttm); ts.left = ptt.x+ "px"; ts.top = ptt.y+ "px"; - ts.width = this.width.value * ttm.a+ "px"; - ts.height = this.height.value * ttm.d+ "px"; - if (ttm.b !== 0 || ttm.c !== 0 || this.paint.fillopacity != 1) {//フィルター プロパティを使うと、PNGの透過性がなくなるので注意 + ts.width = this.width.value * ttm[0][0]+ "px"; + ts.height = this.height.value * ttm[1][1]+ "px"; + if (ttm[1][0] !== 0 || ttm[0][1] !== 0 || this.paint.fillopacity != 1) {//フィルター プロパティを使うと、PNGの透過性がなくなるので注意 ts.filter = "progid:DXImageTransform.Microsoft.Matrix progid:DXImageTransform.Microsoft.Alpha"; var ttfi = this.tar.filters.item('DXImageTransform.Microsoft.Matrix'); ttfi.M11 = 1; - ttfi.M12 = ttm.b; - ttfi.M21 = ttm.c; + ttfi.M12 = ttm[1][0]; + ttfi.M21 = ttm[0][1]; ttfi.M22 = 1; ttfi.sizingMethod = "auto expand"; var ttfia = this.tar.filters.item('DXImageTransform.Microsoft.Alpha'); @@ -1448,7 +1448,7 @@ break; } } - matri = new Matrix(a,b,c,d,e,f); + matri = [[a,c,e], [b,d,f], [0,0,1]]; matrix = matrix.multiply(matri); lis = com = deg = rad = null; } @@ -1464,8 +1464,8 @@ return this; } Point.prototype.matrixTransform = function pmatrixtransform( /*Matrix*/ m) { - var x = parseInt(m.a * this.x + m.c * this.y + m.e); - var y = parseInt(m.b * this.x + m.d * this.y + m.f); + var x = parseInt(m[0][0] * this.x + m[0][1] * this.y + m[0][2]); + var y = parseInt(m[1][0] * this.x + m[1][1] * this.y + m[1][2]); if (-1 < x && x < 1) {x=1;} if (-1 < y && y < 1) {y=1;} var s = new Point(x,y); @@ -1504,10 +1504,24 @@ var s = new Matrix(this.a * m.a + this.c * m.b,this.b * m.a + this.d * m.b,this.a * m.c + this.c * m.d,this.b * m.c + this.d * m.d,this.a * m.e + this.c * m.f + this.e,this.b * m.e + this.d * m.f + this.f); return s; } +Array.prototype.multiply = function (m) { + var s = [[],[],[]]; + for (var i=0;i<3;++i) { + var n = this[i]; + for (var j=0;j<3;++j) { + s[i][j] = m[0][j]*n[0] + m[1][j]*n[1] + m[2][j]*n[2]; + } + } + return s; +} + //行列式 Matrix.prototype.determinant = function() { return (this.a * this.d - this.b * this.c); } +Array.prototype.determinant = function () { + return (this[0][0] * this[1][1] - this[1][0] * this[0][1]); +} //SVGViewSpecを参照 function STViewSpec( /*element*/ ele) { @@ -1558,7 +1572,7 @@ try { if (!vB) { this._tx = this._ty = 0; - return new Matrix(1, 0, 0, 1, 0, 0); + return [[1, 0, 0], [0, 1, 0], [0, 0, 1]]; } var vbx = vB.x, vby = vB.y, vbw = vB.width, vbh = vB.height; var rw = vw / vbw, rh = vh / vbh; @@ -1607,7 +1621,7 @@ this._ty = ty; ttps.marginLeft = this._tx+ "px"; ttps.marginTop = this._ty+ "px"; - var m = new Matrix(xr, 0, 0, yr, 0, 0); + var m = [[xr, 0, 0], [0, yr, 0], [0, 0, 1]]; return m; } catch(e) {stlog.add(e,1031);} } @@ -1927,10 +1941,12 @@ obst.width = regwv+ "px"; obst.height = reghv+ "px"; ob.coordsize = regwv +" "+ reghv; + var dnd = new Date(); var STdocument = new SVGtoVML(obc,obwidth,obheight,regw,regh); obj.parentNode.insertBefore(ob,obj); STdocument.read(ob); STdocument.set(ob); + alert((new Date()).getTime() - dnd.getTime()); STdocument = obw = obh = regw = regh = null; NAIBU.PaintColor.prototype.cache = {}; //キャッシュの初期化 if (NAIBU.STObject !== void 0) {NAIBU.STObject.next();}