OSDN Git Service

SVGPathElementをpaserIntの代わりに、Math.roundを使って軽量化
authordhrname <dhrname@users.sourceforge.jp>
Tue, 20 Dec 2011 14:13:22 +0000 (23:13 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Tue, 20 Dec 2011 14:13:22 +0000 (23:13 +0900)
org/w3c/dom/svg.js

index 32601d2..0d28a26 100644 (file)
@@ -2535,10 +2535,10 @@ for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を
 };
 
 /*documentは引数の変数として登録しておく*/
-(function(_doc, _pInt, _math) {
+(function(_doc, _math) {
 //freeArg関数はunloadで使う解放処理
 NAIBU.freeArg = function() {
-  SVGPathElement = _doc = _pInt = _math = void 0;
+  SVGPathElement = _doc = _math = void 0;
 };
 //仮のfill属性とstroke属性の処理
 NAIBU._setPaint = function(tar, matrix) {
@@ -3022,11 +3022,11 @@ _sproto._nodeInsertInto = function(evt){
   var tar = evt.target,
       matrix = tar.getScreenCTM(),
       tlist = tar.normalizedPathSegList,
-      _parseInt = _pInt,
       dat = [],
       ma = matrix.a, mb = matrix.b, mc = matrix.c, md = matrix.d, me = matrix.e, mf = matrix.f,
       cname = tar._com._nameCom,
-      isZ = tar._com._isZ, isC = tar._com._isC;
+      isZ = tar._com._isZ, isC = tar._com._isC,
+      mr = _math.round;
   for (var i=0, tli=tlist.numberOfItems;i<tli;++i) {
     var ti = tlist[i],
         tx = ti.x,
@@ -3039,14 +3039,14 @@ _sproto._nodeInsertInto = function(evt){
        *[mb md mf] * [y]
        *[0  0  1 ]   [1]
        */
-      t += [_parseInt(ma*ti.x1 + mc*ti.y1 + me, 10),
-             _parseInt(mb*ti.x1 + md*ti.y1 + mf, 10),
-             _parseInt(ma*ti.x2 + mc*ti.y2 + me, 10),
-             _parseInt(mb*ti.x2 + md*ti.y2 + mf, 10),
-             _parseInt(ma*tx + mc*ty + me, 10),
-             _parseInt(mb*tx + md*ty + mf, 10)].join(" ");
+      t += [mr(ma*ti.x1 + mc*ti.y1 + me),
+             mr(mb*ti.x1 + md*ti.y1 + mf),
+             mr(ma*ti.x2 + mc*ti.y2 + me),
+             mr(mb*ti.x2 + md*ti.y2 + mf),
+             mr(ma*tx + mc*ty + me),
+             mr(mb*tx + md*ty + mf)].join(" ");
     } else if (!isZ[tps]) {
-      t += _parseInt(ma*tx + mc*ty + me, 10)+ " " +_parseInt(mb*tx + md*ty + mf, 10);
+      t += mr(ma*tx + mc*ty + me)+ " " +mr(mb*tx + md*ty + mf);
     }
     dat[i] = t;
   }
@@ -3057,7 +3057,7 @@ _sproto._nodeInsertInto = function(evt){
   tt.coordsize = vi.width.baseVal.value + " " + vi.height.baseVal.value;
   NAIBU._setPaint(tar, matrix);
   delete tar._cacheMatrix;
-  evt = tar = dat = t = tx = ty = matrix = tlist = x = y = _parseInt = ma = mb = mc = md = me = mf = vi = isZ = isC = i = tli = tps = ti = cname = tt = void 0;
+  evt = tar = dat = t = tx = ty = matrix = tlist = x = y = mr = ma = mb = mc = md = me = mf = vi = isZ = isC = i = tli = tps = ti = cname = tt = void 0;
 };
 _sproto._com = {
   _nameCom : {
@@ -3338,7 +3338,7 @@ _sproto._com = {
   };
 })(SVGPathElement.prototype)
   NAIBU.SVGPathElement = SVGPathElement; //IE8では、SVGPathElementはローカル変数
-})(document, parseInt, Math);
+})(document, Math);
 
 function SVGRectElement(_doc) {
   SVGElement.apply(this);