Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Painting shapes in Javascript

Is there any good alternative to the html5-element canvas to paint shapes like hexagons using javascript, that works cross-browser (including the horrible IE6)?

I have been using jQuery and jQuery maphighlight for this, but it doesn't give me enough possibilities to manipulate the shapes and colors after it's first rendered.

Am I missing some features in jQuery maphighlight, or are there any other plugin for either jQuery or mootools, that can provide me with this painting capabilities?

like image 516
elzapp Avatar asked Jun 04 '09 08:06

elzapp


People also ask

Can you draw with JavaScript?

Steps for drawing a line in JavaScript First, create a new line by calling the beginPath() method. Second, move the drawing cursor to the point (x,y) without drawing a line by calling the moveTo(x, y) . Finally, draw a line from the previous point to the point (x,y) by calling the lineTo(x,y) method.

Can we draw shapes in HTML5?

We can create many shapes like rectangle, circle, squares, cone, and other custom shapes. HTML5 provides us many elements to create different shapes like Canvas curves and Canvas paths. In this article, we are trying to create some basic shapes of the HTML5 Canvas.


1 Answers

You should take a look at RaphaelJS. It is a JavaScript, cross-browser wrapper library around Canvas, SVG, and VML (an IE-only vector markup language that predates SVG, used in IE6). Using RaphaelJS, you can generate a very wide range of vector graphics using JS that is compatible with a very broad range of browsers.

http://raphaeljs.com/

RaphaelJS is also very compatible with jQuery, and follows a lot of the same call-chaining that you see in jQuery. The two make a great pair.

like image 171
jrista Avatar answered Oct 28 '22 23:10

jrista