Moshu's Canvas Library

Description

This is an attempt to vectorialize the CANVAS element. The library transforms working with pixels into working with objects.

This is the 4'th version of this library i believe. At each iteration i found issues with my initial design, and had to re-model it. Inductively we can conclude this will also change, and hopefully improved, as long as i maintain interest in playing with the CANVAS. One can find the previous iterations here:
Iteration 1
Iteration 2
Iteration 3

Characteristics

  • Lightweight
  • Independant - does not use other libraries
  • Cross browser - it seems to work on all modern browsers

Shapes

All supported shapes at this time are polygon based. This is due to problems with determining collisions of type circle-polygon, circle-image, polygon-image, image-image, etc.

Supported shapes

  • Polygon - base polygon constructed by providing the array of all vertices

Special polygon derivations:

  • RegullarPolygon
  • Can create a regular polygon (polygon with all sides equal), with any number of vertices. At the extreme we can create a polygon based circle with this.

  • Line

  • Triangle

  • Rectangle

  • Image
  • We support image, but only when approximated to a polygon - namely the containing rectangle