OSDN Git Service

Support the paced mode in the object
authordhrname <dhrname@users.sourceforge.jp>
Sat, 7 Mar 2015 13:54:09 +0000 (22:54 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Sat, 7 Mar 2015 13:54:09 +0000 (22:54 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index fa6f393..45f4981 100644 (file)
@@ -555,17 +555,31 @@ base("$from").of( {
    \r
    /*keySpline属性の値を設定*/\r
    keySpline: null,\r
+   \r
+   /*全体の行列ノルム(距離)*/\r
+   norm: 1,\r
       \r
    /*与えられたアニメーションの進捗率を使った時間の圧縮率を計算するための関数を返す*/\r
    call: function() {\r
-     this.to.call();\r
-     return function(t) {\r
-       /*tは進捗率*/\r
-       !this.keyTime && (t = 0);\r
-       t = t / this.keyTime;\r
-       return isNaN(t) ? "0"\r
-                       : this.to.advance(t);\r
-     }.bind(this);\r
+     if (this.mode === "linear") {\r
+       this.to.call();\r
+       return function(t) {\r
+         /*tは進捗率*/\r
+         !this.keyTime && (t = 0);\r
+         t = t / this.keyTime;\r
+         return isNaN(t) ? "0"\r
+                         : this.to.advance(t);\r
+       }.bind(this);\r
+     } else if (this.mode === "paced") {\r
+       /*keyTimes属性は無視され、ベクトルの距離の割合から計算される*/\r
+       this.keyTime = this.to.distance(this.to.from) / this.norm;\r
+       return function(t) {\r
+         !this.keyTime && (t = 0);\r
+         t = t / this.keyTime;\r
+         return isNaN(t) ? "0"\r
+                         : this.to.advance(t);\r
+       }.bind(this);\r
+     }\r
    }\r
 } ).to = base("$from").$to;\r
 //#endif // _SMIL_IDL_\r
index 8597779..9ea02df 100644 (file)
@@ -3098,11 +3098,12 @@ describe("SMIL Animation Spec", function() {
    } );\r
   describe("A $calcMode object", function() {\r
     var calc = base("$calcMode"),\r
-        to = calc.to;\r
+        to = calc.to,\r
+        from;\r
      beforeEach( function() {\r
        calc = calc.up();\r
        calc.to = base("$from").up().mix( {string: "1"} );\r
-       calc.to.from = base("$from").up().mix( {string: "0"} );\r
+       from = calc.to.from = base("$from").up().mix( {string: "0"} );\r
      } );\r
     /*境界条件を調べておく (limit value analysis)*/\r
     it("should be this for the value  (limit value analysis)", function() {\r
@@ -3116,9 +3117,23 @@ describe("SMIL Animation Spec", function() {
       \r
       calc.keyTime = 0;\r
       expect(calc.call()(1)).toBe("0");\r
+      \r
+      /*paced mode*/\r
+      calc.mode = "paced";\r
+      expect(calc.norm).toEqual(1);\r
+      calc.to.from = from;\r
+      expect(calc.call()(0)).toBe("0");\r
+      expect(calc.keyTime).toBe(1);\r
+      calc.to.from = from;\r
+      expect(calc.call()(1)).toBe("1");\r
+      \r
+      calc.keyTime = 0;\r
+      calc.to.from = from;\r
+      expect(calc.call()(1)).toBe("1");\r
     } );\r
     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
     it("should be this for the value (the valid partion)", function() {\r
+      calc.mode = "linear";\r
       calc.keyTime = 0.5;\r
       calc.to.degit = 1;\r
       expect(calc.call()(0.2)).toBe("0.4");\r