svnno****@sourc*****
svnno****@sourc*****
2011年 10月 14日 (金) 22:28:39 JST
Revision: 3007 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=3007 Author: dhrname Date: 2011-10-14 22:28:39 +0900 (Fri, 14 Oct 2011) Log Message: ----------- SVGPathElementの関数呼び出しを整理して軽量化 Modified Paths: -------------- branches/08x/087/org/w3c/dom/svg.js Modified: branches/08x/087/org/w3c/dom/svg.js =================================================================== --- branches/08x/087/org/w3c/dom/svg.js 2011-10-14 13:09:03 UTC (rev 3006) +++ branches/08x/087/org/w3c/dom/svg.js 2011-10-14 13:28:39 UTC (rev 3007) @@ -2708,17 +2708,18 @@ isZ = taco._isZ, isM = taco._isM, isC = taco._isC, - isL = taco._isL; + isL = taco._isL, + tcc = tar.createSVGPathSegCurvetoCubicAbs, + tcll = tar.createSVGPathSegLinetoAbs; for (var i=0;i<dli;++i) { var di = dd[i].match(sgs), - s, - tcc = tar.createSVGPathSegCurvetoCubicAbs; + s; for (var j=1, dii=di[0], dili=di.length; j < dili; ++j) { if (isC[dii]) { s = tcc(+di[j+4], +di[j+5], +di[j], +di[j+1], +di[j+2], +di[j+3]); j += 5; } else if (isL[dii]) { - s = tar.createSVGPathSegLinetoAbs(+di[j], +di[j+1]); + s = tcll(+di[j], +di[j+1]); ++j; } else if (isM[dii]) { s = tar.createSVGPathSegMovetoAbs(+di[j], +di[j+1]); @@ -2772,7 +2773,7 @@ tlist.appendItem(s); } } - di = s = tcc = sgs = dd = void 0; + di = s = sgs = dd = void 0; /*以下の処理は、pathSegListからnormalizedPathSegListへの *変換をする処理。相対座標を絶対座標に変換して、M、L、Cコマンドに正規化していく */ @@ -2805,7 +2806,7 @@ */ var tg = tlist.getItem(j-1); if (tg.pathSegTypeAsLetter === "M") { - tnl.appendItem(tar.createSVGPathSegLinetoAbs(cx, cy)); + tnl.appendItem(tcll(cx, cy)); continue; } } @@ -2816,7 +2817,7 @@ if (j !== 0) { var tg = tlist.getItem(j-1); if (tg.pathSegTypeAsLetter === "m") { - tnl.appendItem(tar.createSVGPathSegLinetoAbs(cx, cy)); + tnl.appendItem(tcll(cx, cy)); continue; } } @@ -2824,9 +2825,9 @@ starty = cy; tnl.appendItem(tar.createSVGPathSegMovetoAbs(cx, cy)); } else if (dii === "l") { - tnl.appendItem(tar.createSVGPathSegLinetoAbs(cx, cy)); + tnl.appendItem(tcll(cx, cy)); } else if (dii === "c") { - tnl.appendItem(tar.createSVGPathSegCurvetoCubicAbs(cx, cy, ti.x1+rx, ti.y1+ry, ti.x2+rx, ti.y2+ry)); + tnl.appendItem(tcc(cx, cy, ti.x1+rx, ti.y1+ry, ti.x2+rx, ti.y2+ry)); } else if (isZ[dii]) { cx = startx; cy = starty; @@ -2835,12 +2836,12 @@ xn = 2*cx - ti.x1; yn = 2*cy - ti.y1; //2次スプライン曲線は近似的な3次ベジェ曲線に変換している - tnl.appendItem(tar.createSVGPathSegCurvetoCubicAbs(cx, cy, (rx + 2*ti.x1) / 3, (ry + 2*ti.y1) / 3, (2*ti.x1 + cx) / 3, (2*ti.y1 + cy) / 3)); + tnl.appendItem(tcc(cx, cy, (rx + 2*ti.x1) / 3, (ry + 2*ti.y1) / 3, (2*ti.x1 + cx) / 3, (2*ti.y1 + cy) / 3)); } else if (dii === "q") { var x1 = ti.x1 + rx, y1 = ti.y1 + ry; xn = 2*cx - x1; yn = 2*cy - y1; - tnl.appendItem(tar.createSVGPathSegCurvetoCubicAbs(cx, cy, (rx + 2*x1) / 3, (ry + 2*y1) / 3, (2*x1 + cx) / 3, (2*y1 + cy) / 3)); + tnl.appendItem(tcc(cx, cy, (rx + 2*x1) / 3, (ry + 2*y1) / 3, (2*x1 + cx) / 3, (2*y1 + cy) / 3)); x1 = y1 = void 0; } else if (dii === "A" || dii === "a") { (function(ti, cx, cy, rx, ry, tar, tnl) { //変数を隠蔽するためのfunction @@ -2907,7 +2908,7 @@ y3 = spsir1*mc + cpsir2*ms + ty, dx = -t * (cpsir1*ms + spsir2*mc), dy = -t * (spsir1*ms - cpsir2*mc); - tnl.appendItem(tar.createSVGPathSegCurvetoCubicAbs(x3, y3, x2, y2, x3-dx, y3-dy)); + tnl.appendItem(tcc(x3, y3, x2, y2, x3-dx, y3-dy)); x2 = x3 + dx; y2 = y3 + dy; } @@ -2927,7 +2928,7 @@ var x1 = rx, y1 = ry; } - tnl.appendItem(tar.createSVGPathSegCurvetoCubicAbs(cx, cy, x1, y1, ti.x2, ti.y2)); + tnl.appendItem(tcc(cx, cy, x1, y1, ti.x2, ti.y2)); x1 = y1 = void 0; } else if (dii === "s") { if (j !== 0) { @@ -2943,7 +2944,7 @@ var x1 = rx, y1 = ry; } - tnl.appendItem(tar.createSVGPathSegCurvetoCubicAbs(cx, cy, x1, y1, ti.x2+rx, ti.y2+ry)); + tnl.appendItem(tcc(cx, cy, x1, y1, ti.x2+rx, ti.y2+ry)); x1 = y1 = void 0; } else if (dii === "T" || dii === "t") { if (j !== 0) { @@ -2955,21 +2956,21 @@ } else { xn = rx, yn = ry; } - tnl.appendItem(tar.createSVGPathSegCurvetoCubicAbs(cx, cy, (rx + 2*xn) / 3, (ry + 2*yn) / 3, (2*xn + cx) / 3, (2*yn + cy) / 3)); + tnl.appendItem(tcc(cx, cy, (rx + 2*xn) / 3, (ry + 2*yn) / 3, (2*xn + cx) / 3, (2*yn + cy) / 3)); xn = 2*cx - xn; yn = 2*cy - yn; xx1 = yy1 = void 0; } else if (dii === "H" || dii === "h") { - tnl.appendItem(tar.createSVGPathSegLinetoAbs(cx, ry)); + tnl.appendItem(tcll(cx, ry)); cy = ry; //勝手にti.yが0としているため } else if (dii === "V" || dii === "v") { - tnl.appendItem(tar.createSVGPathSegLinetoAbs(rx, cy)); + tnl.appendItem(tcll(rx, cy)); cx = rx; } } } } - evt = tar = taco = cx = cy = xn = yn = startx = starty = tnl = tlist = ti = dii = ts = isZ = isM = isL = isC = s = void 0; + evt = tar = taco = cx = cy = xn = yn = startx = starty = tnl = tlist = ti = dii = ts = isZ = isM = isL = isC = s = tcc = tcll = void 0; }; _sproto._nodeInsert = function(evt){ var tar = evt.target;