Drawing half of a Bezier path in Raphael

Posted by Fibericon on Stack Overflow See other posts from Stack Overflow or by Fibericon
Published on 2011-01-12T04:40:20Z Indexed on 2011/01/12 5:53 UTC
Read the original article Hit count: 302

Let's say I have a cubic Bezier path as follows (formatted for use with the Raphael path function):

M55 246S55 247 55 248

Just an example. This was taken from my drawing application, where I use the cursor to draw a line when the user holds the mouse button down, kind of like a pencil or marker. I'm using jquery's mousemove event to draw the line between two points every time the user moves the mouse. There is another (the reference point) that is taken before the line is drawn, so that the Bezier curve can be created.

Here's my question: is it possible to make Raphael only draw half of a given path? I'm aware of the getSubpath() function, but if my understanding of Bezier curves is correct, it would be rather difficult to calculate the second argument. The problem with the animate function is that it creates double lines (that is, it creates the curved line that I want, and the boxy line around it which should not be shown, possibly because the mouse is being moved faster than the animation can handle).

Of course, if my approach itself is flawed in some way (or my understanding of the possible solutions), I'd like to hear it. Any help would be appreciated.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery