\r
/*計算モードを定めるための計算実体\r
*補間の細かい制御などを行う*/\r
- base("$calcMode").mix({\r
+base("$calcMode").mix({\r
/*計算モード (calcMode属性の値)*/\r
mode: "linear",\r
\r
}\r
tkey = void 0;\r
return isNaN(t) ? this.string\r
- : this.to.advance(t);\r
+ : this.to__.advance(t);\r
},\r
\r
/*discreteモードのときには、上記の_f関数の代わりに、以下の関数を用いる*/\r
if (isNaN(t)) {\r
return this.string;\r
} else if (t === 1) {\r
- return this.to.string;\r
+ return this.to__.string;\r
} else {\r
- return this.to.advance(0);\r
+ return this.to__.advance(0);\r
}\r
}\r
}).of( {\r
/*無効だった場合の呈示値*/\r
string: "",\r
\r
+ /*$fromオブジェクトを使っているが、toオブジェクトを指している*/\r
+ to: base("$from").$to,\r
+ \r
/*与えられたアニメーションの進捗率を使った時間の圧縮率を計算して呈示値を返すための関数を作る*/\r
call: function() {\r
var f = this._f.bind(this);\r
if (this.mode === "linear") {\r
- this.to.call();\r
return f;\r
} else if (this.mode === "paced") {\r
/*keyTimes属性は無視され、ベクトルの距離の割合から計算される*/\r
- this.keyTime = this.to.distance(this.to.from__) / this.norm;\r
+ this.keyTime = this.to__.distance(this.to__.from__) / this.norm;\r
return f;\r
} else if (this.mode === "spline") {\r
var tk = this.keySplines,\r
return tf;\r
}\r
}\r
- this.to.call();\r
var x2 = tk[0],\r
y2 = tk[1],\r
x3 = tk[2],\r
&& ( (x3 === 1) || (x3 === 0) )\r
&& (y3 === 1) ) {\r
/*linearモードと同じ効果 (収束ではない可能性を考慮)*/\r
- this.to.call();\r
return f;\r
}\r
var tkey = this.keyTime;\r
return f(Ay*t*t*t + By*t*t + Cy*t);\r
};\r
} else if (this.mode === "discrete") {\r
- this.to.call();\r
return this.funcForDiscrete.bind(this);\r
}\r
}\r
-} ).to = base("$from").$to;\r
+} );\r
\r
\r
/*ニュートン法により、三次方程式 a0x^3 + a1x^2 + a2x + a3 の解を求める\r
call: function() {\r
return function (t) {\r
return isNaN(t) ? this.string\r
- : this.to.advance(1);\r
+ : this.to__.advance(1);\r
}.bind(this);\r
}\r
} \r
var attrValue = ele.parentNode.getAttributeNS(null, this.attrName);\r
ele.addEventListener("beginEvent", function(evt) {\r
to.forEach( function(x) {\r
- x.to.setAdditive(attrValue);\r
+ x.to__.setAdditive(attrValue);\r
} )\r
}, false);\r
}\r
if (ele.getAttributeNS(null, "accumulate") === "sum") {\r
ele.addEventListener("repeatEvent", function(evt) {\r
to.forEach( function(x) {\r
- x.to.call();\r
- x.to.setAccumulate(evt.detail);\r
+ x.to__.call();\r
+ x.to__.setAccumulate(evt.detail);\r
} )\r
}, false);\r
}\r
var s = this.$attribute.setValues.apply(this, arguments),\r
degits = this.degits;\r
s && s.forEach(function(x) {\r
- x.to.degit = degits;\r
+ x.to__.degit = degits;\r
} );\r
degits = void 0;\r
return s;\r
var aa = new Array(to.length);\r
for (var i=0;i<to.length;++i) {\r
var x = to[i];\r
- x.to.string = toRGB(x.to.string);\r
- x.to.from.string = toRGB(x.to.from.string);\r
+ x.to__.string = toRGB(x.to__.string);\r
+ x.to__.from__.string = toRGB(x.to__.from__.string);\r
var s = x.call();\r
/*x.keyTimeプロパティは区間を示しているため、区切り時刻に変換しておく\r
* startKeyTimeプロパティは区間のスタート時点\r
from;\r
beforeEach( function() {\r
calc = base("$calcMode").up();\r
- calc.to = base("$from").up().mix( {string: "1"} );\r
- from = calc.to.from__ = base("$from").up().mix( {string: "0"} );\r
+ calc.to__ = base("$from").up().mix( {string: "1"} );\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
/*paced mode*/\r
calc.mode = "paced";\r
expect(calc.norm).toBe(1);\r
- calc.to.from__ = from;\r
+ calc.to__.from__ = from;\r
expect(calc.call()(0)).toBe("0");\r
expect(calc.keyTime).toBe(1);\r
- calc.to.from__ = from;\r
+ calc.to__.from__ = from;\r
expect(calc.call()(1)).toBe("1");\r
\r
calc.keyTime = 0;\r
- calc.to.from__ = from;\r
+ calc.to__.from__ = from;\r
expect(calc.call()(1)).toBe("1");\r
\r
/*discrete mode*/\r
calc.mode = "discrete";\r
- calc.to.from__ = from;\r
+ calc.to__.from__ = from;\r
calc.keyTime = 1;\r
expect(calc.call()(0)).toBe("0");\r
expect(calc.call()(1)).toBe("1");\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
+ calc.to__.degit = 1;\r
expect(calc.call()(0.2)).toBe("0.4");\r
expect(calc.call()(0.3)).toBe("0.6");\r
/*もう一度確かめる*/\r
\r
calc = base("$calcMode").up();\r
calc.keyTime = 0.2;\r
- calc.to = base("$from").up();\r
- calc.to.from__ = base("$from").up(); \r
- calc.to.from__.string = "0s";\r
- calc.to.string = "1s";\r
- calc.to.degit = 1;\r
+ calc.to__ = base("$from").up();\r
+ calc.to__.from__ = base("$from").up(); \r
+ calc.to__.from__.string = "0s";\r
+ calc.to__.string = "1s";\r
+ calc.to__.degit = 1;\r
expect(calc.call()(0.1)).toBe("0.5s");\r
\r
calc = base("$calcMode").up();\r
calc.keyTime = 0.5;\r
- calc.to = base("$from").up();\r
- calc.to.from__ = base("$from").up(); \r
- calc.to.from__.string = "rgb(100, 20, 32)";\r
- calc.to.string = "rgb(0, 10, 50)";\r
+ calc.to__ = base("$from").up();\r
+ calc.to__.from__ = base("$from").up(); \r
+ calc.to__.from__.string = "rgb(100, 20, 32)";\r
+ calc.to__.string = "rgb(0, 10, 50)";\r
expect(calc.call()(0.25)).toBe("rgb(50, 15, 41)");\r
\r
/*paced mode*/\r
- calc.to = base("$from").up();\r
- calc.to.from__ = base("$from").up(); \r
+ calc.to__ = base("$from").up();\r
+ calc.to__.from__ = base("$from").up(); \r
calc.mode = "paced";\r
calc.norm = 100;\r
- calc.to.from__.string = "0s";\r
- calc.to.string = "20s";\r
- calc.to.degit = 1;\r
+ calc.to__.from__.string = "0s";\r
+ calc.to__.string = "20s";\r
+ calc.to__.degit = 1;\r
calc.initToEval();\r
expect(calc.call()(0.1)).toBe("10.0s");\r
expect(calc.keyTime).toBe(0.2);\r
\r
- calc.to = base("$from").up();\r
- calc.to.from__ = base("$from").up(); \r
+ calc.to__ = base("$from").up();\r
+ calc.to__.from__ = base("$from").up(); \r
calc.mode = "paced";\r
calc.norm = 100;\r
- calc.to.from__.string = "rgb(0, 0, 20)";\r
- calc.to.string = "rgb(0, 0, 0)";\r
+ calc.to__.from__.string = "rgb(0, 0, 20)";\r
+ calc.to__.string = "rgb(0, 0, 0)";\r
calc.initToEval();\r
expect(calc.call()(0.1)).toBe("rgb(0, 0, 10)");\r
expect(calc.keyTime).toBe(0.2);\r
\r
/*discrete mode*/\r
- calc.to = base("$from").up();\r
- calc.to.from__ = base("$from").up(); \r
+ calc.to__ = base("$from").up();\r
+ calc.to__.from__ = base("$from").up(); \r
calc.mode = "discrete";\r
calc.keyTime = 0.5;\r
- calc.to.degit = 1;\r
- calc.to.string = "1";\r
- calc.to.from__.string = "0.5";\r
+ calc.to__.degit = 1;\r
+ calc.to__.string = "1";\r
+ calc.to__.from__.string = "0.5";\r
calc.initToEval();\r
expect(calc.call()(0.2)).toBe("0.5");\r
expect(calc.call()(0.3)).toBe("0.5");\r
/*もう一度確かめる*/\r
expect(calc.call()(0.2)).toBe("0.5");\r
\r
- calc.to = base("$from").up();\r
- calc.to.from__ = base("$from").up(); \r
+ calc.to__ = base("$from").up();\r
+ calc.to__.from__ = base("$from").up(); \r
calc.mode = "discrete";\r
calc.keyTime = 0.5;\r
- calc.to.degit = 1;\r
- calc.to.string = "block";\r
- calc.to.from__.string = "inline";\r
+ calc.to__.degit = 1;\r
+ calc.to__.string = "block";\r
+ calc.to__.from__.string = "inline";\r
calc.initToEval();\r
expect(calc.call()(0.2)).toBe("inline");\r
expect(calc.call()(0.3)).toBe("inline");\r
\r
- calc.to = base("$from").up();\r
- calc.to.from__ = base("$from").up(); \r
+ calc.to__ = base("$from").up();\r
+ calc.to__.from__ = base("$from").up(); \r
calc.mode = "linear";\r
calc.keyTime = 1;\r
- calc.to.degit = 1;\r
- calc.to.string = "1 1";\r
- calc.to.from__.string = "0.0 1";\r
+ calc.to__.degit = 1;\r
+ calc.to__.string = "1 1";\r
+ calc.to__.from__.string = "0.0 1";\r
calc.initToEval();\r
expect(calc.call()(0.2)).toBe("0.2 1.0");\r
expect(calc.call()(0.3)).toBe("0.3 1.0");\r
\r
calc = base("$calcMode").up();\r
calc.mode = "paced";\r
- calc.to.from__ = from;\r
+ calc.to__.from__ = from;\r
expect(calc.call()()).toBe(calc.string);\r
\r
calc = base("$calcMode").up();\r
calc.mode = "spline";\r
expect( calc.call()("undef")).toBe(Math.PI);\r
calc.keySplines = [0, 0, 1, 1];\r
- calc.to.degit = 1;\r
- calc.to.from__ = from;\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
+ 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
+ calc.to__.from__ = from;\r
expect(calc.call()(0.5)).toBe(bezier(0,0, 0,0, 1,1, 1,1)(0.5)+"");\r
\r
df(0,0, 0,0, 1,1, 1,1, 0.1);\r
};\r
calc.mode = "spline";\r
calc.keySplines = [0, 0.5, 0.5, 1];\r
- calc.to.degit = 1;\r
+ calc.to__.degit = 1;\r
var b = bezier(0,0, 0,0.5, 0.5,1, 1,1);\r
expect(calc.call()(0)).toBe(b(0).y+".0");\r
- calc.to.from__ = from;\r
+ calc.to__.from__ = from;\r
expect(calc.call()(1)).toBe(b(1).y+".0");\r
- calc.to.from__ = from;\r
+ calc.to__.from__ = from;\r
expect(calc.call()( b(0.5).x )).toBe(b(0.5).y.toFixed(1));\r
\r
var ff = function(k) {\r
calc.keySplines = k;\r
- calc.to.degit = 10;\r
+ calc.to__.degit = 10;\r
var b = bezier(0,0, k[0],k[1], k[2],k[3], 1,1),\r
epsilon = 1e-5; //誤差\r
expect(calc.call()(0)).toBe(b(0).y.toFixed(10));\r
- calc.to.from__ = from;\r
+ calc.to__.from__ = from;\r
expect(calc.call()(1)).toBe(b(1).y.toFixed(10));\r
- calc.to.from__ = from;\r
+ calc.to__.from__ = from;\r
b = b(Math.random());\r
expect(Math.abs(calc.call()(b.x) - b.y.toFixed(10))).toBeLessThan(epsilon);\r
};\r
it("should be this for the value (the invalid partion on a spline mode )", function() {\r
calc.mode = "spline";\r
calc.keySplines = [0, NaN, 1, 1];\r
- calc.to.degit = 1;\r
- calc.to.from__ = from;\r
+ calc.to__.degit = 1;\r
+ calc.to__.from__ = from;\r
expect( calc.up().call()("undef")).toBe(Math.PI);\r
\r
\r
calc.keySplines = [0, 0, 1, 2];\r
- calc.to.degit = 1;\r
- calc.to.from__ = from;\r
+ calc.to__.degit = 1;\r
+ calc.to__.from__ = from;\r
expect( calc.up().call()("undef")).toBe(Math.PI);\r
\r
calc.keySplines = null;\r
- calc.to.degit = 1;\r
- calc.to.from__ = from;\r
+ calc.to__.degit = 1;\r
+ calc.to__.from__ = from;\r
expect( calc.up().call()("undef")).toBe(Math.PI);\r
} );\r
} );\r
s.setAttributeNS(null, "from", "0");\r
attr.setKey(s);\r
s.setAttributeNS(null, "to", "0");\r
- expect(attr.setKey(s)[0].to.from__.string).toBe("0");\r
- expect(attr.setKey(s)[0].to.string).toBe("0");\r
+ expect(attr.setKey(s)[0].to__.from__.string).toBe("0");\r
+ expect(attr.setKey(s)[0].to__.string).toBe("0");\r
s.setAttributeNS(null, "by", "0");\r
attr.setKey(s);\r
s.setAttributeNS(null, "values", "0;2");\r
- expect(attr.setKey(s)[0].to.from__.string).toBe("0");\r
- expect(attr.setKey(s)[0].to.string).toBe("2");\r
+ expect(attr.setKey(s)[0].to__.from__.string).toBe("0");\r
+ expect(attr.setKey(s)[0].to__.string).toBe("2");\r
\r
s.setAttributeNS(null, "keyTimes", "0;0.1");\r
expect(attr.setKey(s)[0].keyTime).toBe(0.1);\r