paper.clear()之后如何重画拉斐尔对象 [英] How to redraw raphael object after paper.clear()
问题描述
这是我的代码.我已经尝试过,但是找不到任何答案.所以有人帮我
This is my code. i have tried but cant find any answer. so anyone help me
move = function (dx, dy) {
paper.clear();
this.attr({x: this.ox + dx, y: this.oy + dy});
var arrow = paper.arrow(this.ox,this.oy,this.attrs.x,this.attrs.y,8);
}
rect2.drag(move, start);
推荐答案
我认为您不需要清理(除非您有这样做的特定原因...).拉斐尔不喜欢在html5画布上绘图.要设置动画时,无需清除并重绘所有内容. Raphael(和SVG)中的每个元素本身就是一个对象.更改圆心将自动更新该圆在图形中的位置.
I don't think you need to be clearing (unless you have a specific reason for doing so...). Raphael isn't like drawing on the html5 canvas; you don't need to clear and redraw everything when you want to animate. Each element within Raphael (and SVG) is an object in and of itself. Changing the centre of a circle will automatically update where that circle is in your drawing.
只要您拥有该对象的句柄,就可以根据自己的喜好操纵它,而不必要求重新绘制它.
As long as you have a handle to the object you can manipulate it to your hearts content without having to request it be redrawn.
这篇关于paper.clear()之后如何重画拉斐尔对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!