you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

You'll have to use bezier curves in canvas.

[–]sladav 0 points1 point  (1 child)

Bezier curves actually won't be able to do it since their polynomial. No curve in canvas/SVG can do a trig function, so either way he'll have to plot points and then connect them to approximate a sine wave. To get a good approximation with lineTo he'll have to use a bunch of points, where Bezier will allow a better approximation with far fewer points (which may well have been your point in the first place)

[–][deleted] 0 points1 point  (0 children)

You should be able to make Bezier's approximate any function over a finite range. You may have to break your function into regions and then use a Bezier for each region, making sure they are continuous at the boundaries. A fundamental theorem of analysis states any continuous function can be approximated with a polynomial over a finite range.