Take the following AS3 that will draw a curved line using curveTo()
:
var line:Shape = new Shape();
line.x = line.y = 20;
line.graphics.lineStyle(2, 0xFF0000);
line.graphics.curveTo(200, 200, 200, 0);
addChild(line);
The resulting visual is:
Now I want something to be able to follow this path; how can I convert this visual into a list of coordinates? I struggle with any advanced mathematics, but I'm assuming there's an obvious (to some) formula that curveTo()
uses to create the above that I can replicate and amend to create my desired list.
The result may end up looking like this (assuming an offset of about 5px between points).
Vector.<Point> = [
new Point(20, 20),
new Point(23, 23),
new Point(27, 28),
new Point(33, 32),
new Point(40, 37)
/* ...etc... */
];
The result will be used for things such as creating a rain of projectiles that follow the following paths, for example: