views:

33

answers:

1

Is it possible? I'm learning canvas at the moment, and while it's fun to position objects programmatically, it would be most interesting to come up with a way to align them to a curve.

E.g. align a series of squares back to back along a wavy line or a circle.

+2  A: 

It's possible but there's no built-in API to do it, afaik.

Which means you'd need to either use a third-party library (not sure of one that could do this, but there are plenty of libraries e.g. Raphael, Processing.js, etc. you could check out), or build your own functions, which would be a bit math-intensive.

fig
I'm all for math intensive! Any suggestions? Currently I've rolled a simple spiral using basic trig but I've yet to think up a way to align objects to a bezier curve, for example.
mitjak
mitjak, unfortunately my math really, really sucks. :) Maybe this would help in some way: http://mathext.sourceforge.net/. Do take a look at existing javascript graphics/animation libraries as well, they may have utility functions used internally in addition to anything in the API.
fig
Cool. Will do! Thanks!
mitjak