Drawing Graphics with Canvas


Another example built using canvas, works on Firefox 1.5b & Safari 1.3/2.0:

An example of a rotating cube in a canvas element. You can modify the direction of the rotation using either the mouse-wheel or the arrow keys.

Canvas Support Questions

I'm currently working on a polynomial grapher script, which I intend to turn into a fully featured Javascript grapher, but I'm having some weird issues, either with my implementation of my polynomial functions (used to for determining the y position from the x position) or with the canvas element.

In my example here - - if you use the default function provided, and change the x minimum to -29, the graph shifts over as expected. However, if you shift it over one more to an x minimum of -30, the entire graph disappears. Why this is happening, I have no idea, although it does appear that the value of y to be graphed goes under -32000 at this point which may be some kind of inherent limitation in the canvas element.

Yeah writing this down helped me solve the issue, which was exactly what I expected. Canvas elements won't accept starting points below -32000 or above 32000 (presumably in any direction) and disregard the entire path if this happens. I've adjusted my code for now to put a cap on the absolute value of the y values at below 32000.

As an aside, I'm not pleased with the lack of text implementation with the Canvas element. It's forced me to use an annoying work-around which I haven't quite sorted out yet. If anyone could give me any advice on this issue, that would terrific.

Document Tags and Contributors

 Contributors to this page: Dwees, Powermacx
 Last updated by: Dwees,