[Sie-announce] SIEコード [1786] polygon要素とpolyline要素の実装

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 4月 11日 (日) 21:02:42 JST


Revision: 1786
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1786
Author:   dhrname
Date:     2010-04-11 21:02:42 +0900 (Sun, 11 Apr 2010)

Log Message:
-----------
polygon要素とpolyline要素の実装

Modified Paths:
--------------
    branches/ufltima/dom/svg.js

Modified: branches/ufltima/dom/svg.js
===================================================================
--- branches/ufltima/dom/svg.js	2010-04-09 14:43:25 UTC (rev 1785)
+++ branches/ufltima/dom/svg.js	2010-04-11 12:02:42 UTC (rev 1786)
@@ -1163,7 +1163,7 @@
     var obje = document.getElementsByTagName("object");
     for (var i=0, objli=1;i<objli;++i) {
       var objei = {style:{}};//obje[i];
-      xmlhttp.open("GET", "../svggen/shapes-polyline-01-t.svg", true);//objei.getAttribute("data"), true);
+      xmlhttp.open("GET", "../svggen/shapes-polygon-01-t.svg", true);//objei.getAttribute("data"), true);
       xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
       xmlhttp.onreadystatechange = function() {
         if (xmlhttp.readyState === 4  &&  xmlhttp.status === 200) {
@@ -2492,13 +2492,19 @@
   /*readonly SVGPointList*/   this.animatedPoints = this.points = new SVGPointList();
   this.addEventListener("DOMAttrModified", function(evt){
     var tar = evt.target;
-    var tp = tar.points, par = tar.ownerDocument.documentElement;
-    var list = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/);
-    for (var i=0, p, lili=list.length;i<lili;i+=2) {
-      p = par.createSVGPoint();
-      p.x = parseFloat(list[i]);
-      p.y = parseFloat(list[i+1]);
-      tp.appendItem(p);
+    if (evt.attrName === "points") {
+      var tp = tar.points, par = tar.ownerDocument.documentElement;
+      var list = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/);
+      for (var i=0, p, lili=list.length;i<lili;i+=2) {
+        if (isNaN(list[i])) {
+          --i;
+          continue;
+        }
+        p = par.createSVGPoint();
+        p.x = parseFloat(list[i]);
+        p.y = parseFloat(list[i+1]);
+        tp.appendItem(p);
+      }
     }
     evt = tar = list = tp = par = p = null;
   }, false);
@@ -2512,13 +2518,11 @@
       var tar = evt.target, tp = tar.points;
       //以下は、配列listそのものをCTMで座標変換していく処理
       var ctm = tar.getScreenCTM();
-      for (var i=0, list = [], lili=tp.numberOfItems;i<lili;) {
+      for (var i=0, list = [], lili=tp.numberOfItems;i<lili;++i) {
         var p = tp.getItem(i);
         var pmt = p.matrixTransform(ctm);
-        list[i] = pmt.x;
-        ++i;
-        list[i] = pmt.y;
-        ++i;
+        list[2*i] = pmt.x;
+        list[2*i + 1] = pmt.y;
         p = pmt = null;
       }
       list.splice(2, 0, "l");
@@ -2543,6 +2547,24 @@
   this._tar = document.createElement("v:shape");
   //interface SVGAnimatedPoints
   /*readonly SVGPointList*/   this.animatedPoints = this.points = new SVGPointList();
+  this.addEventListener("DOMAttrModified", function(evt){
+    var tar = evt.target;
+    if (evt.attrName === "points") {
+      var tp = tar.points, par = tar.ownerDocument.documentElement;
+      var list = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/);
+      for (var i=0, p, lili=list.length;i<lili;i+=2) {
+        if (isNaN(list[i])) {
+          --i;
+          continue;
+        }
+        p = par.createSVGPoint();
+        p.x = parseFloat(list[i]);
+        p.y = parseFloat(list[i+1]);
+        tp.appendItem(p);
+      }
+    }
+    evt = tar = list = tp = par = p = null;
+  }, false);
   this.addEventListener("DOMNodeInserted", function(evt){
     if (evt.eventPhase === Event.BUBBLING_PHASE) {
       return; //強制終了させる
@@ -2550,6 +2572,25 @@
     var tar = evt.target;
     tar.parentNode._tar.appendChild(tar._tar);
     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
+      var tar = evt.target, tp = tar.points;
+      //以下は、配列listそのものをCTMで座標変換していく処理
+      var ctm = tar.getScreenCTM();
+      for (var i=0, list = [], lili=tp.numberOfItems;i<lili;++i) {
+        var p = tp.getItem(i);
+        var pmt = p.matrixTransform(ctm);
+        list[2*i] = pmt.x;
+        list[2*i + 1] = pmt.y;
+        p = pmt = null;
+      }
+      list.splice(2, 0, "l");
+      var dat = "m" + list.join(" ") + "x e";
+      //VMLに結び付けていく
+      var ele = tar._tar, vi = tar.ownerDocument.documentElement.viewport;
+      var w = vi.width, h = vi.hight;
+      ele.path = dat;
+      ele.coordsize = w + " " + h;
+      NAIBU._setPaint(tar, ctm);
+      evt = ele = tar = dat = list = ctm = w = h = null;
     }, false);
     evt = tar = null;
   }, false);




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