1
我不明白如何在某個點旋轉我的對象。這是JavaScript我Raphael 2.0 - 如何正確設置旋轉點
// create needle
var rsr = Raphael('rsr', '320', '240');
var needle = rsr.path("m 156.74443,870.84631 -2.26177,119.38851
4.38851,0 z"); needle.attr({id: 'needle',parent: 'layer1',fill:
'#ff6600',stroke: '#000000',"stroke-width": '0.61',"stroke-linecap":
'butt',"stroke-linejoin": 'miter',"stroke-miterlimit": '4',"stroke-
opacity": '1',"stroke-dasharray": 'none'});
needle.rotate(0);
needle.transform("t0,-812.36218").data('id', 'needle');
// get needle bounding box
var needleBox = needle.getBBox();
// calculate rotation point (bottom middle)
var x_rotate_point = needleBox.x + (needleBox.width/2);
var y_rotate_point = needleBox.y + needleBox.height;
// rotate needle
needle.attr({rotation: 0}).animate({transform:"r45,"+x_rotate_point
+","+y_rotate_point}, 6000);
// Creates circle at rotation point
var circle = rsr.circle(x_rotate_point, y_rotate_point, 10);
circle.attr("fill", "#f00");
circle.attr("stroke", "#fff");
我創建了一個虛擬圈來檢查,如果我的我的中心點座標是正確的 ,它是,但它不圍繞該點旋轉: -/
當我在不同的框架中創建標量總是看起來要走的路,但是這個邏輯似乎並沒有很好地轉化成Raphael 2.0。
我做了它的谷歌,並找到了一些條目,但問題似乎是 舊版本,因爲很多 東西已被更改或不推薦使用。