Raphaël is a JavaScript library for drawing on web pages. Basically one draw shapes of different types, likes circles, text, rectangles, images.
- Download "raphael.min.js" from http://raphaeljs.com/ to your app/assets/javascript directory
or get the unminifed version here https://raw.githubusercontent.com/DmitryBaranovskiy/raphael/master/raphael.js
-
Include the JS file in the head of your documents
<script type="text/javascript" src="raphael-min.js"></script>
-
Objects are drawn on paper elements created by calling the
Raphael(...)
function.
Example: var paper = Raphael("paper1", 500,500);
This creates a 500 x 500 "paper" within an HTML element with an ID of "paper".
- Paths and shapes are drawn within that paper. Here is an example of a simple rectangle.
var rect1 = paper.rect(20,30,100,12).attr({fill: "orange"});
There are many available functions supported by SVG to create shapes and draw anything. A detailed list can be found at http://www.w3.org/TR/SVG/paths.html
- Website - http://raphaeljs.com/
- Full Documentation - http://raphaeljs.com/reference.html
- Detailed tutorial - http://cancerbero.mbarreneche.com/raphaeltut/#sec-getting-started