[Sie-announce] SIEコード [2012] SVGRadialGradientElementオブジェクトの修正

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 9月 24日 (金) 22:07:59 JST


Revision: 2012
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2012
Author:   dhrname
Date:     2010-09-24 22:07:58 +0900 (Fri, 24 Sep 2010)

Log Message:
-----------
SVGRadialGradientElementオブジェクトの修正

Modified Paths:
--------------
    branches/06x/061/org/w3c/dom/svg.js

Modified: branches/06x/061/org/w3c/dom/svg.js
===================================================================
--- branches/06x/061/org/w3c/dom/svg.js	2010-09-22 12:33:29 UTC (rev 2011)
+++ branches/06x/061/org/w3c/dom/svg.js	2010-09-24 13:07:58 UTC (rev 2012)
@@ -3705,7 +3705,7 @@
 };
 
 function SVGColorProfileElement() { 
-  SVGElement.apply(this, arguments);
+  SVGElement.apply(this);
   /*DOMString*/      this._local;
                          // raises DOMException on setting
                        // (NOTE: is prefixed by "_"
@@ -3720,7 +3720,7 @@
 SVGColorProfileElement.prototype = new SVGElement();
 
 function SVGColorProfileRule() { 
-  SVGCSSRule.apply(this, arguments);
+  SVGCSSRule.apply(this);
   /*DOMString*/      this.src;
   /*DOMString*/      this.name;
   /*unsigned short*/ this.renderingIntent;
@@ -3766,6 +3766,8 @@
       // When colors attribute is used, the meanings of opacity and o:opacity2 are reversed.
       ele.setAttribute("opacity", opacity[length-1]+ "");
       ele.setAttribute("o:opacity2", opacity[0]+ "");
+      /*SVGRadialGradientElementインターフェースで利用する*/
+      grad._color = color;
       grad = ele = stops = lengh = color = colors = opacity = null;        
     }
     evt = t = null;
@@ -3827,7 +3829,8 @@
       var cx = grad.cx.baseVal.value, cy = grad.cy.baseVal.value;
       var r = rx = ry = grad.r.baseVal.value;
       var tarrect = tar.getBBox();
-      var el = tar.ownerDocument.documentElement.viewport.width, et = tar.ownerDocument.documentElement.viewport.height, er = 0, eb = 0;
+      var el = tar.ownerDocument.documentElement.viewBox.baseVal.width, et = tar.ownerDocument.documentElement.viewBox.baseVal.height, er = 0, eb = 0;
+      var data = tar._tar.path.value;
       var units = grad.getAttributeNS(null, "gradientUnits");
       if (!units || units === "objectBoundingBox") {
         //%の場合は小数点に変換(10% -> 0.1)
@@ -3843,31 +3846,45 @@
       }
       var gt = grad.getAttributeNS(null, "gradientTransform");
       if (gt) {
-        grad.setAttributeNS(null, "transform",gt);
-        matrix = grad.getCTM();
+        grad.setAttributeNS(null, "transform", gt);
       }
+      matrix = tar.getScreenCTM().multiply(grad.getCTM());
       el = cx - rx; et = cy - ry; er = cx + rx; eb = cy + ry;
       var rrx = rx * 0.55228, rry = ry * 0.55228;
       var list = ["m", cx,et, "c", cx-rrx,et, el,cy-rry, el,cy, el,cy+rry, cx-rrx,eb, cx,eb, cx+rrx,eb, er,cy+rry, er,cy, er,cy-rry, cx+rrx,et, cx,et, "x e"];
-      var pl = new PList(list);
-      var plm = pl.matrixTransform(matrix);
-      var ellipse = plm.list.join(" ");
+      for (var i = 0, lili = list.length; i < lili;) {
+        if (isNaN(list[i])) { //コマンド文字は読み飛ばす
+          ++i;
+          continue;
+        }
+        var p = grad.ownerDocument.documentElement.createSVGPoint();
+        p.x = parseFloat(list[i]);
+        p.y = parseFloat(list[i+1]);
+        var pmt = p.matrixTransform(matrix);
+        list[i] = pmt.x;
+        i++;
+        list[i] = pmt.y;
+        i++;
+        p = pmt = null;
+      }
+      var ellipse = list.join(" ");
       var outline = document.getElementById("_NAIBU_outline");
       var background = document.createElement("div"), bstyle = background.style;
       bstyle.position = "absolute";
       bstyle.display = "inline-block";
-      bstyle.textAlign = "left"; bstyle.top = "0px"; bstyle.left = "0px"; bstyle.width = this.w+ "px"; bstyle.height = this.h+ "px";
+      var w = tar.ownerDocument.documentElement.viewBox.baseVal.width, h = tar.ownerDocument.documentElement.viewBox.baseVal.height;
+      bstyle.textAlign = "left"; bstyle.top = "0px"; bstyle.left = "0px"; bstyle.width = w+ "px"; bstyle.height = h+ "px";
       outline.appendChild(background);
       bstyle.filter = "progid:DXImageTransform.Microsoft.Compositor";
       background.filters.item('DXImageTransform.Microsoft.Compositor').Function = 23;
-      var circle = '<v:shape style="display:inline-block; position:relative; antialias:false; top:0px; left:0px;" coordsize="' +this.w+ ' ' +this.h+ '" path="' +ellipse+ '" stroked="f">' +ele.outerHTML+ '</v:shape>';
-      background.innerHTML = '<v:shape style="display:inline-block; position:relative; top:0px; left:0px;" coordsize="' +this.w+ ' ' +this.h+ '" path="' +data+ '" stroked="f" fillcolor="' +color[color.length-1]+ '" ></v:shape>';
+      var circle = '<v:shape style="display:inline-block; position:relative; antialias:false; top:0px; left:0px;" coordsize="' +w+ ' ' +h+ '" path="' +ellipse+ '" stroked="f">' +ele.outerHTML+ '</v:shape>';
+      background.innerHTML = '<v:shape style="display:inline-block; position:relative; top:0px; left:0px;" coordsize="' +w+ ' ' +h+ '" path="' +data+ '" stroked="f" fillcolor="' +grad._color[grad._color.length-1]+ '" ></v:shape>';
       background.filters[0].apply();
       background.innerHTML = circle;
       background.filters[0].play();
-      ele.parentNode.insertBefore(background, ele);
-      ele.parentNode.filled = "false";
-      ellipse = circle = data = list = pl = plm = gt = cx = cy = r = null;
+      tar._tar.insertBefore(background, tar._tar.firstChild);
+      tar._tar.filled = "false";
+      ellipse = circle = data = list = gt = cx = cy = r = w = h = null;
     } else if (!ele.parentNode){
       tar._tar.appendChild(ele);
     }




Sie-announce メーリングリストの案内
Back to archive index