OSDN Git Service

Modify the getRotate method
authordhrname <dhrname@users.sourceforge.jp>
Wed, 27 Jul 2016 12:03:38 +0000 (21:03 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Wed, 27 Jul 2016 12:03:38 +0000 (21:03 +0900)
org/w3c/dom/smil.js

index 3dbb712..f88b38d 100644 (file)
@@ -1703,7 +1703,9 @@ base("$calcMode").up("$attribute").mix( {
       /*パスセグメントの数値を求めてから、動いている図形の傾き角度r(ラジアンではなく度数)を算出する*/\r
       var length = path.getPathSegAtLength(advanceLength),\r
           seg = path.pathSegList.getItem(length),\r
-          command = seg.pathSegTypeAsLetter;\r
+          command = seg.pathSegTypeAsLetter,\r
+          /*pi*180ではEdgeでうまく作動しない(原因は不明)*/\r
+          pi = Math.PI;\r
       if (command === "M") {\r
         /*次のセグメントがどのコマンドによるかで、計算方式が違う*/\r
         var nextSeg = path.pathSegList.getItem(length+1),\r
@@ -1711,13 +1713,13 @@ base("$calcMode").up("$attribute").mix( {
         if (nextCommand === "M") {\r
           return "";\r
         } else if (nextCommand === "L") {\r
-          return ") rotate(" +(Math.atan2(nextSeg.y-seg.y, nextSeg.x-seg.x)/Math.Pi*180 + rotate)+ "";\r
+          return ") rotate(" +(Math.atan2(nextSeg.y-seg.y, nextSeg.x-seg.x)/pi*180 + rotate)+ "";\r
         } else if (nextCommand === "C") {\r
-          return ") rotate(" +(Math.atan2(nextSeg.y1-seg.y, nextSeg.x1-seg.x)/Math.Pi*180 + rotate)+ "";\r
+          return ") rotate(" +(Math.atan2(nextSeg.y1-seg.y, nextSeg.x1-seg.x)/pi*180 + rotate)+ "";\r
         }\r
       } else if ((command === "L") && (length-1 >= 0)) {\r
         var preSeg = path.pathSegList.getItem(length-1);\r
-        return ") rotate(" +(Math.atan2(seg.y-preSeg.y, seg.x-preSeg.x)/Math.Pi*180 + rotate)+ "";\r
+        return ") rotate(" +(Math.atan2(seg.y-preSeg.y, seg.x-preSeg.x)/pi*180 + rotate)+ "";\r
       } else if (command === "C") {\r
         /*3次ベジェ曲線を微分する方法はニュートン法など数値解析の必要があるので、\r
          * 以下の通り、別の方法を採用する。\r
@@ -1728,8 +1730,7 @@ base("$calcMode").up("$attribute").mix( {
              y = point.y;\r
          /*一歩進んだ点*/\r
          point = path.getPointAtLength(advanceLength+1);\r
-         console.log(Math.PI);\r
-         return ") rotate(" +(Math.atan2(point.y-y, point.x-x)/Math.PI*180 + rotate)+ "";\r
+         return ") rotate(" +(Math.atan2(point.y-y, point.x-x)/pi*180 + rotate)+ "";\r
       }\r
     },\r
     \r