ここで色をアニメーション化するための別のオプションを読みました:http://community.createjs.com/discussions/easeljs/4637-graphics-colour-animation
createjsinject-methodを利用します。提供されたコード例から関連するコードをコピーし、自分自身で少し説明しました。
ドキュメントによると:
inject(callback、data):任意のContext2D(別名Canvas)API呼び出しをGraphicsキューに注入するためのメソッドを提供します。指定されたコールバック関数は、他の描画命令と順番に呼び出されます(...)
このメソッドを使用すると、たとえば、ネイティブのcontext2d fillstyleを変更して、easeljsがキャンバスに描画するために使用する塗りつぶしの色を変更できます。
ここでは、createjsに独自のsetColor関数(以下で定義)について説明します。したがって、この関数は、再描画するたびに自動的に実行されます。
var shape = new createjs.Shape();
shape.graphics.beginFill(createjs.Graphics.getRGB(255, 0, 0));
shape.graphics.inject(setColor, data)
shape.graphics.drawCircle(0, 0, 10);
stage.addChild(shape);
キャンバスのネイティブfillStyleメソッドを呼び出すsetColor関数の定義:
function setColor(o) {
// sets the context2D's fillStyle to the current value of data.fill:
this.fillStyle = o.fill; // "this" will resolve to the canvas's Context2D.
}
そして、塗りつぶしの値を変更するティック関数:
function tick(evt) {
count = (count+3)%360;
// update the value of the data object:
data.fill = createjs.Graphics.getHSL(count, 100, 50);
// redraw the stage:
stage.update();
}