http://raphaeljs.com/ball.htmlのようなアイテムがある場合、特定のインスタンスの色を変更するために DOM 経由で変更するにはどうすればよいですか?
元:
Raphael.fn.ball = function (x, y, r, hue) {
hue = hue || 0;
return this.set(
this.ellipse(x, y + r - r / 5, r, r / 2).attr({fill: "rhsb(" + hue + ", 1, .25)-hsb(" + hue + ", 1, .25)", stroke: "none", opacity: 0}),
this.ellipse(x, y, r, r).attr({fill: "r(.5,.9)hsb(" + hue + ", 1, .75)-hsb(" + hue + ", .5, .25)", stroke: "none"}),
this.ellipse(x, y, r - r / 5, r - r / 20).attr({stroke: "none", fill: "r(.5,.1)#ccc-#ccc", opacity: 0})
);
};
function drawBall(div_id, color) {
var X = Raphael(div_id), x = 100, y = 80, r = 50;
X.ball(x, y, r, color);
}
ドキュメントに "Ball" (document.write(active_div, 0.3459912) を作成しましたが、色を変更したいと思います。
同じ div で drawBall を呼び出すと、DIV に別の「ボール」が作成されます。