OSDN Git Service

Modify the Spec for a 'spleine' mode
authordhrname <dhrname@users.sourceforge.jp>
Sun, 22 Mar 2015 13:50:44 +0000 (22:50 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Sun, 22 Mar 2015 13:50:44 +0000 (22:50 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index cfe1c6d..9dcb6dc 100644 (file)
@@ -586,16 +586,18 @@ base("$from").of( {
        this.keyTime = this.to.distance(this.to.from) / this.norm;\r
        return f;\r
      } else if (this.mode === "spline") {\r
-      var x = 0,\r
-          y = 0,\r
-          bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {\r
-            return function (t) {\r
-              x = (x4-3*(x3+x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1;\r
-              y = (y4-3*(y3+y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1;\r
-              return y+"";\r
-            };\r
-          },\r
-          tk = this.keySplines;\r
+       this.to.call();\r
+       var x = 0,\r
+           y = 0,\r
+           that = this,\r
+           bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {\r
+              return function (t) {\r
+                x = (x4-3*(x3+x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1;\r
+                y = (y4-3*(y3+y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1;\r
+                return f(y);\r
+             };\r
+           },\r
+           tk = this.keySplines;\r
        return bezier(0, 0, tk[0], tk[1], tk[2], tk[3], 1, 1);\r
      } else if (this.mode === "discrete") {\r
        return function (t) {\r
index 2f4a21c..40c6aa3 100644 (file)
@@ -3214,6 +3214,7 @@ describe("SMIL Animation Spec", function() {
       calc.mode = "discrete";\r
       expect(calc.call()()).toEqual(calc.string);\r
     } );\r
+    \r
     /*splineモードの境界条件を調べておく (limit value analysis)*/\r
     it("should be this for the value  (spline mode limit value analysis)", function() {\r
       /*3次ベジェ曲線の数式はこのページを参考にした http://geom.web.fc2.com/geometry/bezier/cubic.html*/\r
@@ -3228,12 +3229,36 @@ describe("SMIL Animation Spec", function() {
           };\r
       expect(calc.keySplines).toBeNull();\r
       calc.mode = "spline";\r
+      expect( function() {\r
+        calc.call();\r
+      }).toThrow();\r
       calc.keySplines = [0, 0, 1, 1];\r
-      expect(calc.call()(0)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0)+"");\r
-      expect(calc.call()(1)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(1)+"");\r
+      calc.to.degit = 1;\r
+      calc.to.from = from;\r
+      expect(calc.call()(0)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0)+".0");\r
+      calc.to.from = from;\r
+      expect(calc.call()(1)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(1)+".0");\r
+      calc.to.from = from;\r
+      expect(calc.call()(0.5)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0.5)+"");\r
     } );\r
     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
     it("should be this for the value (the valid partion on a spline mode )", function() {\r
+      var x = 0,\r
+          y = 0,\r
+          bezier = function (x1, y1, x2, y2, x3, y3, x4, y4) {\r
+            return function (t) {\r
+              x = (x4-3*(x3+x2)-x1)*t*t*t + 3*(x3-2*x2+x1)*t*t + 3*(x2-x1)*t + x1;\r
+              y = (y4-3*(y3+y2)-y1)*t*t*t + 3*(y3-2*y2+y1)*t*t + 3*(y2-y1)*t + y1;\r
+              return y;\r
+            };\r
+          };\r
+      calc.mode = "spline";\r
+      calc.keySplines = [0, 0.5, 0.5, 1];\r
+      calc.to.degit = 1;\r
+      expect(calc.call()(0)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0)+".0");\r
+      calc.to.from = from;\r
+      expect(calc.call()(1)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(1)+".0");\r
+      calc.to.from = from;\r
     } );\r
     /*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
     it("should be this for the value (the invalid partion on a spline mode )", function() {\r