An HTML5 canvas reference
Learn how to use the canvas tag API
With the new html5 specification comes a whole bag of new goodies including a new tag - canvas. This tag is effectively like a piece of paper on your page onto which you can draw and this is what the majority of the RGraph library is based on. The drawing is done by javascript and there's a whole bunch of functions available to you to draw shapes and lines with.
Because canvas uses a "fire and forget" methodology there is no dom for you to get references to shapes already drawn on the canvas - so you must remember the coordinates of the shapes yourself. It's because of this that the canvas tag is so fast.
Despite this though, there is a Path2D object that has been added, along with other new features that have been specified by the W3C that will allow you to retain path information and test at a later time for hits etc. The Path2D object is described here. So on to the information!
The canvas element
The canvas state
Drawing rectangles
Path functions
- The beginPath function
- The closePath function
- The moveTo function
- The lineTo function
- The rect function
- The roundRect function
- The arc function
- The arcTo function
- The ellipse function
- The quadraticCurveTo function
- The bezierCurveTo function
- The stroke function
- The fill function
- The clip function
- The isPointInPath function
- The isPointInStroke function
- The Path2D object
Linedash options
Color options
- The fillStyle property
- The strokeStyle property
- Linear gradients
- Radial gradients
- The createPattern function
Images
Transformations
- The translate function
- The rotate function
- The scale function
- The transform function
- The setTransform function