I love Points

I’d never really looked into the new Point class until tonight, and I must say, I love it. Just for the organizational aspect alone, rather than tracking individual x and y coordinates, but it has some other nice features, like interpolate, which will find a point between two points from 0% to 100%, so for instance:

Point.interpolate(a, b, .5);

will get you the midpoint, x and y between points a and b. Instead of having to plug in the formula, which isn’t difficult (x1+x2)/2,(y1+y2)/2 but when you’ve got long expressions, long confusing expressions for each one, it adds up.
I went from something like this:

_line.graphics.curveTo(m1.x + m1.mod.width + buffer, deltaY, (((m1.x + m1.mod.width + buffer) - (m2.x -buffer)) / 2) + m2.x -buffer,deltaY);

(You can’t see it but it’s shooting off the right side of the screen)
to this:

_line.graphics.curveTo(c.x, c.y, cd.x, cd.y);
Posted in AS3

Leave a Reply

Your email address will not be published. Required fields are marked *