4
我对以下演示有疑问 - http://raphaeljs.com/hand.html。RaphaelJS - 我需要帮助了解变换
下面是示例代码...
var r = Raphael("holder", 640, 480), angle = 0;
while (angle < 360) {
var color = Raphael.getColor();
(function(t, c) {
r.circle(320, 450, 20).attr({
stroke : c,
fill : c,
transform : t,
"fill-opacity" : .4
}).click(function() {
s.animate({
transform : t,
stroke : c
}, 2000, "bounce");
}).mouseover(function() {
this.animate({
"fill-opacity" : .75
}, 500);
}).mouseout(function() {
this.animate({
"fill-opacity" : .4
}, 500);
});
})("r" + angle + " 320 240", color);
angle += 30;
}
Raphael.getColor.reset();
var s = r.set();
s.push(r.path("M320,240c-50,100,50,110,0,190").attr({
fill : "none",
"stroke-width" : 2
}));
s.push(r.circle(320, 450, 20).attr({
fill : "none",
"stroke-width" : 2
}));
s.push(r.circle(320, 240, 5).attr({
fill : "none",
"stroke-width" : 10
}));
s.attr({
stroke : Raphael.getColor()
});
我是对下面的代码行的问题...
("r" + angle + " 320 240", color);
在匿名函数圆最初绘制在半径为20的320,450处。然后例如在角度为30时应用变换(“r30 320 240”)。
该变换如何工作?我读这个变换的方式是将圆圈旋转30度到320,450,然后水平移动320(向右)和240垂直向下移动。
但我显然读这个转换错了,因为这不是发生了什么事情。
我在想什么?
由于
非常好,谢谢马特,这很有道理。我很感谢你的榜样,它帮助你清除了一切。 在特定点画圆,然后围绕另一点旋转。再次感谢!我会尽力投票,但不知道我有没有足够的声望。 – RDotLee 2012-04-02 00:39:10