1.2.3
[raphael] / reference.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
2    "http://www.w3.org/TR/html4/strict.dtd">
3 <html lang="en">
4     <head>
5         <title>Raphaël Reference</title>
6         <meta http-equiv="content-language" content="en">
7         <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8         <meta name="author" content="Dmitry Baranovskiy">
9         <meta name="description" content="Vector Graphics JavaScript Library">
10         <meta name="keywords" content="JavaScript Library, Raphael, SVG, VML">
11         <meta name="viewport" content="width=450; user-scalable=no">
12         <link rel="shortcut icon" href="/favicon16.png" type="image/x-icon">
13         <link rel="stylesheet" href="raphael.css" type="text/css" charset="utf-8" media="screen,projection">
14         <link rel="stylesheet" type="text/css" media="print" href="print.css">
15         <link rel="shortcut icon" href="/favicon16.png" type="image/x-icon">
16         <link media="only screen and (max-device-width: 480px)" href="iphone.css" type="text/css" rel="stylesheet">
17         <script src="jquery.js" type="text/javascript" charset="utf-8"></script>
18         <script src="dmitry.js" type="text/javascript" charset="utf-8"></script>
19         <script src="raphael.js" type="text/javascript" charset="utf-8"></script>
20         <script src="museo.js" type="text/javascript" charset="utf-8"></script>
21
22
23     </head>
24     <body class="raphael" id="reference">
25         <div id="header">
26             <a href="http://twitter.com/statuses/user_timeline/17180567.atom" id="rss" name="rss">rss</a>
27             <h1>
28                 Raphaël—JavaScript Library
29             </h1>
30         </div>
31         <div id="content">
32             <div>
33                 <div>
34                     <div id="column-1">
35                         <h2>Main Function</h2>
36                         <h3 id="Raphael">
37                             Raphael
38                         </h3>
39                         <p>
40                             Creates a canvas object on which to draw. You must do this first, as all future calls to drawing methods from this instance will be bound to this canvas.
41                         </p>
42                         <h4>Parameters</h4>
43                         <ol>
44                             <li>container <em>HTMLElement</em> or <em>string</em></li>
45                             <li>width <em>number</em></li>
46                             <li>height <em>number</em></li>
47                         </ol>
48                         <p>or</p>
49                         <ol>
50                             <li>x <em>number</em></li>
51                             <li>y <em>number</em></li>
52                             <li>width <em>number</em></li>
53                             <li>height <em>number</em></li>
54                         </ol>
55                         <h4>Usage</h4>
56                         <pre class="javascript code"><code>// Each of the following examples create a canvas that is 320px wide by 200px high
57 // Canvas is created at the viewport's 10,50 coordinate
58 var paper = Raphael(10, 50, 320, 200);
59 // Canvas is created at the top left corner of the #notepad element (or its top right corner in dir="rtl" elements)
60 var paper = Raphael(document.getElementById("notepad"), 320, 200);
61 // Same as above
62 var paper = Raphael("notepad", 320, 200);</code></pre>
63                         <h2 id="Element">
64                             Element’s generic methods
65                         </h2>
66                         <p>
67                             Each object created on the canvas shares these same generic methods:
68                         </p>
69                         <h3 id="node">
70                             node
71                         </h3>
72                         <p>
73                             Gives you a reference to the DOM object, so you can assign event handlers or just mess around.
74                         </p>
75                         <h4>Usage</h4>
76                         <pre class="javascript code"><code>var c = paper.circle(10, 10, 10); // draw a circle at coordinate 10,10 with radius of 10
77 c.node.onclick = function () { c.attr("fill", "red"); };</code></pre>
78                         <h3 id="paper">
79                             paper
80                         </h3>
81                         <p>
82                             Internal reference to “paper” where object drawn. Mainly for use in plugins and element extensions.
83                         </p>
84                         <h4>Usage</h4>
85                         <pre class="javascript code"><code>Raphael.el.cross = function () {
86     this.attr({fill: "red"});
87     this.paper.path("M10,10L50,50M50,10L10,50").attr({stroke: "red"});
88 }</code></pre>
89                         <h3 id="remove">
90                             remove
91                         </h3>
92                         <p>
93                             Removes element from the DOM. You can’t use it after this method call.
94                         </p>
95                         <h4>Usage</h4>
96                         <pre class="javascript code"><code>var c = paper.circle(10, 10, 10);
97 c.remove();</code></pre>
98                         <h3 id="hide">
99                             hide
100                         </h3>
101                         <p>
102                             Makes element invisible.
103                         </p>
104                         <h4>Usage</h4>
105                         <pre class="javascript code"><code>var c = paper.circle(10, 10, 10);
106 c.hide();</code></pre>
107                         <h3 id="show">
108                             show
109                         </h3>
110                         <p>
111                             Makes element visible.
112                         </p>
113                         <h4>Usage</h4>
114                         <pre class="javascript code"><code>var c = paper.circle(10, 10, 10);
115 c.show();</code></pre>
116                         <h3 id="rotate">
117                             rotate
118                         </h3>
119                         <p>
120                             Rotates the element by the given degree from its center point.
121                         </p>
122                         <h4>Parameters</h4>
123                         <ol>
124                             <li>degree <em>number</em> Degree of rotation (0 – 360°)</li>
125                             <li>isAbsolute <em>boolean</em> [optional] Specifies is degree is relative to previous position (<code>false</code>) or is it absolute angle (<code>true</code>)</li>
126                         </ol>
127                         <p>or</p>
128                         <ol>
129                             <li>degree <em>number</em> Degree of rotation (0 – 360°)</li>
130                             <li>cx <em>number</em> [optional] X coordinate of the origin of rotation</li>
131                             <li>cY <em>number</em> [optional] Y coordinate of the origin of rotation</li>
132                         </ol>
133                         <h4>Usage</h4>
134                         <pre class="javascript code"><code>var c = paper.circle(10, 10, 10);
135 c.rotate(45);        // rotation is relative
136 c.rotate(45, true);  // rotation is absolute</code></pre>
137                         <h3 id="translate">
138                             translate
139                         </h3>
140                         <p>
141                             Moves the element around the canvas by the given distances.
142                         </p>
143                         <h4>Parameters</h4>
144                         <ol>
145                             <li>dx <em>number</em> Pixels of translation by X axis</li>
146                             <li>dy <em>number</em> Pixels of translation by Y axis</li>
147                         </ol>
148                         <h4>Usage</h4>
149                         <pre class="javascript code"><code>var c = paper.circle(10, 10, 10);
150 c.translate(10, 10); // moves the circle down the canvas, in a diagonal line</code></pre>
151                         <h3 id="scale">
152                             scale
153                         </h3>
154                         <p>
155                             Resizes the element by the given multiplier.
156                         </p>
157                         <h4>Parameters</h4>
158                         <ol>
159                             <li>Xtimes <em>number</em> Amount to scale horizontally</li>
160                             <li>Ytimes <em>number</em> Amount to scale vertically</li>
161                             <li>centerX <em>number</em> [optional] X of the center of scaling, default is the center of the element</li>
162                             <li>centerY <em>number</em> [optional] Y of the center of scaling, default is the center of the element</li>
163                         </ol>
164                         <h4>Usage</h4>
165                         <pre class="javascript code"><code>var c = paper.circle(10, 10, 10);
166 c.scale(1.5, 1.5); // makes the circle 1.5 times larger
167 c.scale(.5, .75);  // makes the circle half as wide, and 75% as high</code></pre>
168                         <h3 id="attr">
169                             attr
170                         </h3>
171                         <p>
172                             Sets the attributes of elements directly.
173                         </p>
174                         <h4>Parameters</h4>
175                         <ol>
176                             <li>attributeName <em>string</em></li>
177                             <li>value <em>string</em></li>
178                         </ol>
179                         <p>or</p>
180                         <ol>
181                             <li>params <em>object</em></li>
182                         </ol>
183                         <p>or</p>
184                         <ol>
185                             <li>attributeName <em>string</em> in this case method returns current value for given attribute name</li>
186                         </ol>
187                         <p>or</p>
188                         <ol>
189                             <li>attributeNames <em>array</em> in this case method returns array of current values for given attribute names</li>
190                         </ol>
191                         <h4>Possible parameters</h4>
192                         <p>Please refer to the <a href="http://www.w3.org/TR/SVG/" title="The W3C Recommendation for the SVG language describes these properties in detail.">SVG specification</a> for an explanation of these parameters.</p>
193                         <ul>
194                             <li>clip-rect <em>string</em> comma or space separated values: x, y, width and height</li>
195                             <li>cx <em>number</em></li>
196                             <li>cy <em>number</em></li>
197                             <li>fill <em>colour</em></li>
198                             <li>fill-opacity <em>number</em></li>
199                             <li>font <em>string</em></li>
200                             <li>font-family <em>string</em></li>
201                             <li>font-size <em>number</em></li>
202                             <li>font-weight <em>string</em></li>
203                             <li>gradient <em>string</em> “‹angle›-‹colour›[-‹colour›[:‹offset›]]*-‹colour›”, example: <samp>"90-#fff-#000"</samp> or <samp>"0-#fff-#f00:20-#000"</samp></li>
204                             <li>height <em>number</em></li>
205                             <li>opacity <em>number</em></li>
206                             <li>path <em>pathString</em> <a href="http://www.w3.org/TR/SVG/paths.html#PathData" title="Details of a path’s data attribute’s format are described in the SVG specification.">SVG path string format</a></li>
207                             <li>r <em>number</em></li>
208                             <li>rotation <em>number</em></li>
209                             <li>rx <em>number</em></li>
210                             <li>ry <em>number</em></li>
211                             <li>scale <em>string</em> comma or space separated values: xtimes, ytimes, cx, cy. See: <a href="#scale">scale</a></li>
212                             <li>src <em>string</em> (URL)</li>
213                             <li>stroke <em>colour</em></li>
214                             <li>stroke-dasharray <em>string</em> [“”, “-”, “.”, “-.”, “-..”, “. ”, “- ”, “--”, “- .”, “--.”, “--..”]</li>
215                             <li>stroke-linecap <em>string</em> [“butt”, “square”, “round”, “miter”]</li>
216                             <li>stroke-linejoin <em>string</em> [“butt”, “square”, “round”, “miter”]</li>
217                             <li>stroke-miterlimit <em>number</em></li>
218                             <li>stroke-opacity <em>number</em></li>
219                             <li>stroke-width <em>number</em></li>
220                             <li>translation <em>string</em> comma or space separated values: x and y</li>
221                             <li>width <em>number</em></li>
222                             <li>x <em>number</em></li>
223                             <li>y <em>number</em></li>
224                         </ul>
225                         <h4>Usage</h4>
226                         <pre class="javascript code"><code>var c = paper.circle(10, 10, 10);
227 c.attr("fill", "black");                              // using strings
228 c.attr({fill: "#000", stroke: "#f00", opacity: 0.5}); // using params object
229 c.attr({gradient: "90-#fff-#000", "stroke-dasharray": "-..", "clip-rect": "10, 10, 100, 100"});</code></pre>
230                         <h3 id="animate">
231                             animate
232                         </h3>
233                         <p>
234                             Changes an attribute from its current value to its specified value in the given amount of milliseconds.
235                         </p>
236                         <h4>Parameters</h4>
237                         <ol>
238                             <li>newAttrs <em>object</em> A parameters object of the animation results. (Not all attributes can be animated.)</li>
239                             <li>ms <em>number</em> The duration of the animation, given in milliseconds.</li>
240                             <li>callback <em>function</em> [optional]</li>
241                         </ol>
242                         <p>or</p>
243                         <ol>
244                             <li>newAttrs <em>object</em> A parameters object of the animation results. (Not all attributes can be animated.)</li>
245                             <li>ms <em>number</em> The duration of the animation, given in milliseconds.</li>
246                             <li>easing <em>string</em> [“>”, “&lt;”, “&lt;&gt;”, “backIn”, “backOut”, “bounce”, “elastic”] [optional]</li>
247                             <li>callback <em>function</em> [optional]</li>
248                         </ol>
249                         <h4>Attributes that can be animated</h4>
250                         <p>The <code>newAttrs</code> parameter accepts an object whose properties are the attributes to animate. However, not all attributes listed in the <code>attr</code> method reference can be animated. The following is a list of those properties that can be animated:</p>
251                         <ul>
252                             <li>clip-rect <em>string</em></li>
253                             <li>cx <em>number</em></li>
254                             <li>cy <em>number</em></li>
255                             <li>fill <em>colour</em></li>
256                             <li>fill-opacity <em>number</em></li>
257                             <li>font-size <em>number</em></li>
258                             <li>height <em>number</em></li>
259                             <li>opacity <em>number</em></li>
260                             <li>path <em>pathString</em></li>
261                             <li>r <em>number</em></li>
262                             <li>rotation <em>string</em></li>
263                             <li>rx <em>number</em></li>
264                             <li>ry <em>number</em></li>
265                             <li>scale <em>string</em></li>
266                             <li>stroke <em>colour</em></li>
267                             <li>stroke-opacity <em>number</em></li>
268                             <li>stroke-width <em>number</em></li>
269                             <li>translation <em>string</em></li>
270                             <li>width <em>number</em></li>
271                             <li>x <em>number</em></li>
272                             <li>y <em>number</em></li>
273                         </ul>
274                         <h4>Easing</h4>
275                         <p>
276                             For easing use built in functions or add your own by adding new functions to <code>Raphael.easing_formulas</code> object. Look at the <a href="easing.html">example of easing usage</a>.
277                         </p>
278                         <h4>Usage</h4>
279                         <pre class="javascript code"><code>var c = paper.circle(10, 10, 10);</code>
280 <code>c.animate({cx: 20, r: 20}, 2000);</code>
281 <code>c.animate({cx: 20, r: 20}, 2000, "bounce");</code></pre>
282                         <h3 id="getBBox">
283                             getBBox
284                         </h3>
285                         <p>
286                             Returns the dimensions of an element.
287                         </p>
288                         <h4>Usage</h4>
289                         <pre class="javascript code"><code>var c = paper.circle(10, 10, 10);</code>
290 <code>var width = c.getBBox().width;</code></pre>
291                         <h3 id="toFront">
292                             toFront
293                         </h3>
294                         <p>
295                             Moves the element so it is the closest to the viewer’s eyes, on top of other elements.
296                         </p>
297                         <h4>Usage</h4>
298                         <pre class="javascript code"><code>var c = paper.circle(10, 10, 10);</code>
299 <code>c.toFront();</code></pre>
300                         <h3 id="toBack">
301                             toBack
302                         </h3>
303                         <p>
304                             Moves the element so it is the furthest from the viewer’s eyes, behind other elements.
305                         </p>
306                         <h4>Usage</h4>
307                         <pre class="javascript code"><code>var c = paper.circle(10, 10, 10);</code>
308 <code>c.toBack();</code></pre>
309                         <h3 id="insertBefore">
310                             insertBefore
311                         </h3>
312                         <p>
313                             Inserts current object before the given one.
314                         </p>
315                         <h4>Usage</h4>
316                         <pre class="javascript code"><code>var r = paper.rect(10, 10, 10, 10);</code>
317 <code>var c = paper.circle(10, 10, 10);</code>
318 <code>c.insertBefore(r);</code></pre>
319                         <h3 id="insertAfter">
320                             insertAfter
321                         </h3>
322                         <p>
323                             Inserts current object after the given one.
324                         </p>
325                         <h4>Usage</h4>
326                         <pre class="javascript code"><code>var r = paper.rect(10, 10, 10, 10);</code>
327 <code>var c = paper.circle(10, 10, 10);</code>
328 <code>r.insertAfter(c);</code></pre>
329                         <h2>Graphic Primitives</h2>
330                         <p>
331                             Methods of “paper” object, created with <code>Raphael</code> function call.
332                         </p>
333                         <h3 id="raphael">
334                             raphael
335                         </h3>
336                         <p>
337                             Internal reference to <code>Raphael</code> object. In case it is not available.
338                         </p>
339                         <h4>Usage</h4>
340                         <pre class="javascript code"><code>Raphael.el.red = function () {
341     var hsb = this.paper.raphael.rgb2hsb(this.attr("fill"));
342     hsb.h = 1;
343     this.attr({fill: this.paper.raphael.hsb2rgb(hsb).hex});
344 }</code></pre>
345                         <h3 id="setSize">
346                             setSize
347                         </h3>
348                         <p>
349                             If you need to change dimensions of the canvas call this method
350                         </p>
351                         <h4>Parameters</h4>
352                         <ol>
353                             <li>width <em>number</em> new width of the canvas</li>
354                             <li>height <em>number</em> new height of the canvas</li>
355                         </ol>
356                         <h3 id="setWindow">
357                             setWindow
358                         </h3>
359                         <p>
360                             Should be called before main Raphael method. Sets which window should be used for drawing. Default is the current one. You need to use it if you want to draw inside <code>iframe</code>
361                         </p>
362                         <h4>Parameters</h4>
363                         <ol>
364                             <li>window <em>object</em></li>
365                         </ol>
366                         <h3 id="getRGB">
367                             getRGB
368                         </h3>
369                         <p>
370                             Parses passes string and returns an color object. Especially usefull for plug-in developers.
371                         </p>
372                         <h4>Parameters</h4>
373                         <ol>
374                             <li>color <em>string</em> Color in form acceptable by library</li>
375                         </ol>
376                         <h4>Usage</h4>
377                         <pre class="javascript code"><code>var stroke = Raphael.getRGB(circle.attr("stroke")).hex</code></pre>
378                         <h3 id="getColor">
379                             getColor
380                         </h3>
381                         <p>
382                             Returns a colour object for the next colour in spectrum
383                         </p>
384                         <h4>Parameters</h4>
385                         <ol>
386                             <li>value <em>number</em> brightness [optional]</li>
387                         </ol>
388                         <h4>Usage</h4>
389                         <pre class="javascript code"><code>var c = paper.path("M10,10L100,100").attr({stroke: Raphael.getColor()});</code></pre>
390                         <h3 id="getColor-reset">
391                             getColor.reset
392                         </h3>
393                         <p>
394                             Resets getColor function, so it will start from the beginning
395                         </p>
396                         <h3 id="registerFont">
397                             registerFont
398                         </h3>
399                         <p>
400                             Adds given font to the registered set of fonts for Raphaël. Should be used as an internal call from within Cufón’s font file. <a href="http://wiki.github.com/sorccu/cufon/about">More about Cufón and how to convert your font form TTF, OTF, etc to JavaScript file</a>. Returns original parameter, so it could be used with chaining.
401                         </p>
402                         <h4>Parameters</h4>
403                         <ol>
404                             <li>font <em>object</em> the font to register</li>
405                         </ol>
406                         <h4>Usage</h4>
407                         <pre class="javascript code"><code>Cufon.registerFont(Raphael.registerFont({…}))</code></pre>
408                         <h3 id="getFont">
409                             getFont
410                         </h3>
411                         <p>
412                             Finds font object in the registered fonts by given parameters. You could specify only one word from the font name, like “Myriad” for “Myriad Pro”.
413                         </p>
414                         <h4>Parameters</h4>
415                         <ol>
416                             <li>family <em>string</em> font family name or any word from it</li>
417                             <li>weight <em>string</em> weight of the font [optional]</li>
418                             <li>style <em>string</em> style of the font [optional]</li>
419                             <li>stretch <em>string</em> stretch of the font [optional]</li>
420                         </ol>
421                         <h4>Usage</h4>
422                         <pre class="javascript code"><code>paper.print(100, 100, "Test string", paper.getFont("Times", 800), 30);</code></pre>
423                         <h3 id="print">
424                             print
425                         </h3>
426                         <div class="sample" id="print-sample"></div>
427                         <p>
428                             Creates set of shapes to represent given font at given position with given size. Result of the method is set object (see <a href="#set">set</a>) which contains each letter as separate path object.
429                         </p>
430                         <h4>Parameters</h4>
431                         <ol>
432                             <li>x <em>number</em> x position of the text</li>
433                             <li>y <em>number</em> y position of the text</li>
434                             <li>text <em>string</em> text to print</li>
435                             <li>font <em>object</em> font object (see <a href="#getFont">getFont</a>)</li>
436                             <li>font_size <em>number</em> size of the font</li>
437                         </ol>
438                         <h4>Usage</h4>
439                         <pre class="javascript code"><code>var txt = r.print(10, 50, "print", r.getFont("Museo"), 30).attr({fill: "#fff"});
440 // following line will paint first letter in red
441 txt[0].attr({fill: "#f00"});</code></pre>
442                         <h3 id="circle">
443                             circle
444                         </h3>
445                         <div class="sample" id="circle-sample"></div>
446                         <p>
447                             Draws a circle.
448                         </p>
449                         <h4>Parameters</h4>
450                         <ol>
451                             <li>x <em>number</em> X coordinate of the centre</li>
452                             <li>y <em>number</em> Y coordinate of the centre</li>
453                             <li>r <em>number</em> radius</li>
454                         </ol>
455                         <h4>Usage</h4>
456                         <pre class="javascript code"><code>var c = paper.circle(50, 50, 40);</code></pre>
457                         <h3 id="rect">
458                             rect
459                         </h3>
460                         <div class="sample" id="rect-sample"></div>
461                         <p>
462                             Draws a rectangle.
463                         </p>
464                         <h4>Parameters</h4>
465                         <ol>
466                             <li>x <em>number</em> X coordinate of top left corner</li>
467                             <li>y <em>number</em> Y coordinate of top left corner</li>
468                             <li>width <em>number</em></li>
469                             <li>height <em>number</em></li>
470                             <li>r <em>number</em> [optional] radius for rounded corners, default is 0</li>
471                         </ol>
472                         <h4>Usage</h4>
473                         <pre class="javascript code"><code>// regular rectangle</code>
474 <code>var c = paper.rect(10, 10, 50, 50);</code>
475 <code>// rectangle with rounded corners</code>
476 <code>var c = paper.rect(40, 40, 50, 50, 10);</code></pre>
477                         <h3 id="ellipse">
478                             ellipse
479                         </h3>
480                         <div class="sample" id="ellipse-sample"></div>
481                         <p>
482                             Draws an ellipse.
483                         </p>
484                         <h4>Parameters</h4>
485                         <ol>
486                             <li>x <em>number</em> X coordinate of the centre</li>
487                             <li>y <em>number</em> X coordinate of the centre</li>
488                             <li>rx <em>number</em> Horisontal radius</li>
489                             <li>ry <em>number</em> Vertical radius</li>
490                         </ol>
491                         <h4>Usage</h4>
492                         <pre class="javascript code"><code>var c = paper.ellipse(50, 50, 40, 20);</code></pre>
493                         <h3 id="image">
494                             image
495                         </h3>
496                         <div class="sample" id="image-sample"></div>
497                         <p>
498                             Embeds an image into the SVG/VML canvas.
499                         </p>
500                         <h4>Parameters</h4>
501                         <ol>
502                             <li>src <em>string</em> URI of the source image</li>
503                             <li>x <em>number</em> X coordinate position</li>
504                             <li>y <em>number</em> Y coordinate position</li>
505                             <li>width <em>number</em> Width of the image</li>
506                             <li>height <em>number</em> Height of the image</li>
507                         </ol>
508                         <h4>Usage</h4>
509                         <pre class="javascript code"><code>var c = paper.image("apple.png", 10, 10, 80, 80);</code></pre>
510                         <h3 id="set">
511                             set
512                         </h3>
513                         <div class="sample" id="set-sample"></div>
514                         <p>
515                             Creates array-like object to keep and operate couple of elements at once. Warning: it doesn’t create any elements for itself in the page.
516                         </p>
517                         <h4>Usage</h4>
518                         <pre class="javascript code"><code>var st = paper.set();</code>
519 <code>st.push(paper.circle(10, 10, 5), paper.circle(30, 10, 5));</code>
520 <code>st.attr({fill: "red"});</code></pre>
521                         <h3 id="text">
522                             text
523                         </h3>
524                         <div class="sample" id="text-sample"></div>
525                         <p>
526                             Draws a text string. If you need line breaks, put “\n” in the string.
527                         </p>
528                         <h4>Parameters</h4>
529                         <ol>
530                             <li>x <em>number</em> X coordinate position.</li>
531                             <li>y <em>number</em> Y coordinate position.</li>
532                             <li>text <em>string</em> The text string to draw.</li>
533                         </ol>
534                         <h4>Usage</h4>
535                         <pre class="javascript code"><code>var t = paper.text(50, 50, "Raphaël\nkicks\nbutt!");</code></pre>
536                         <h3 id="path">
537                             path
538                         </h3>
539                         <div class="sample" id="path-sample"></div>
540                         <p>
541                             Initialises path drawing. You can specify a path by supplying the path data as a second argument.
542                         </p>
543                         <h4>Parameters</h4>
544                         <ol>
545                             <li>pathString <em>string</em> [optional] Path data in <a href="http://www.w3.org/TR/SVG/paths.html#PathData" title="Details of a path's data attribute's format are described in the SVG specification.">SVG path string format</a>.</li>
546                         </ol>
547                         <h4>Usage</h4>
548                         <pre class="javascript code"><code>var c = paper.path("M10 10L90 90");
549 // draw a diagonal line: move to 10,10, line to 90,90</code></pre>
550                         <h3 id="plugins-canvas">
551                             Adding your own methods to canvas
552                         </h3>
553                         <p>
554                             You can add your own method to the canvas. For example if you want to draw pie chart, you can create your own pie chart function and ship it as a Raphaël plugin. To do this you need to extend Raphael.fn object. Please note that you can create your own namespaces inside fn object. Methods will be run in context of canvas anyway. You should alter fn object before Raphaël instance was created, otherwise it will take no effect.
555                         </p>
556                         <h4>Usage</h4>
557                         <pre class="javascript code"><code>Raphael.fn.arrow = function (x1, y1, x2, y2, size) {
558     return this.path(// some code here);
559 };
560 // or create namespace
561 Raphael.fn.mystuff = {
562     arrow: function () {…},
563     star: function () {…},
564     // etc…
565 };
566 var paper = Raphael(10, 10, 630, 480);
567 // then use it
568 paper.arrow(10, 10, 30, 30, 5).attr({fill: "#f00"});
569 paper.mystuff.arrow();
570 paper.mystuff.star();
571 </code></pre>
572                         <h3 id="plugins-elements">
573                             Adding your own methods to elements
574                         </h3>
575                         <p>
576                             You can add your own method to elements. This is usefull when you want to hack default functionality or want to wrap some common transformation or attributes in one method. In difference to canvas mathods, you can redefine element method at any time.
577                         </p>
578                         <h4>Usage</h4>
579                         <pre class="javascript code"><code>Raphael.el.red = function () {
580     this.attr({fill: "#f00"});
581 };
582 // then use it
583 paper.circle(100, 100, 20).red();
584 </code></pre>
585                         <h3 id="colour">
586                             Supported colour formats
587                         </h3>
588                         <p>
589                             You could specify colour in this formats:
590                         </p>
591                         <ul>
592                             <li>Colour name (“red”, “green”, “cornflowerblue”, etc)</li>
593                             <li>#••• — shortened HTML colour: (“#000”, “#fc0”, etc)</li>
594                             <li>#•••••• — full length HTML colour: (“#000000”, “#bd2300”)</li>
595                             <li>rgb(•••, •••, •••) — red, green and blue channels’ values: (“rgb(200, 100, 0)”)</li>
596                             <li>rgb(•••%, •••%, •••%) — same as above, but in %: (“rgb(100%, 175%, 0%)”)</li>
597                             <li>hsb(•••, •••, •••) — hue, saturation and brightness values: (“hsb(0.5, 0.25, 1)”)</li>
598                             <li>hsb(•••%, •••%, •••%) — same as above, but in %</li>
599                             <li>hsl(•••, •••, •••) — same as hsb</li>
600                             <li>hsl(•••%, •••%, •••%) — same as hsb</li>
601                         </ul>
602                         <h4>Usage</h4>
603                         <pre class="javascript code"><code>paper.circle(100, 100, 20).attr({fill: "hsb(1, 255, 200)", stroke: "red"});</code></pre>
604                         <h3 id="safari">
605                             safari
606                         </h3>
607                         <p>
608                             There is an inconvenient rendering bug is Safari (WebKit): sometimes the rendering should be forced. This method should help with dealing with this bug.
609                         </p>
610                         <h4>Usage</h4>
611                         <pre class="javascript code"><code>paper.safari();</code></pre>
612                         <h3 id="ninja-mode">
613                             “Ninja Mode”
614                         </h3>
615                         <p>
616                             If you want to leave no trace of Raphaël (Well, Raphaël creates only one global variable <code>Raphael</code>, but anyway.) You can use <code>ninja</code> method.
617                         </p>
618                         <h4>Usage</h4>
619                         <pre class="javascript code"><code>(function (local_raphael) {
620     var paper = local_raphael(10, 10, 320, 200);
621     …
622 })(Raphael.ninja());
623 </code></pre>
624                     </div>
625                     <div id="column-2">
626                         <h2>
627                             <a href="index.html">Home</a>
628                         </h2>
629                         <h2>
630                             Contents
631                         </h2>
632                         <ul id="contents">
633                             <li>
634                                 <a href="#Raphael"><code>Raphael</code></a>
635                             </li>
636                             <li>
637                                 <a href="#node"><code>node</code></a>
638                             </li>
639                             <li>
640                                 <a href="#paper"><code>paper</code></a>
641                             </li>
642                             <li>
643                                 <a href="#remove"><code>remove</code></a>
644                             </li>
645                             <li>
646                                 <a href="#hide"><code>hide</code></a>
647                             </li>
648                             <li>
649                                 <a href="#show"><code>show</code></a>
650                             </li>
651                             <li>
652                                 <a href="#rotate"><code>rotate</code></a>
653                             </li>
654                             <li>
655                                 <a href="#translate"><code>translate</code></a>
656                             </li>
657                             <li>
658                                 <a href="#scale"><code>scale</code></a>
659                             </li>
660                             <li>
661                                 <a href="#attr"><code>attr</code></a>
662                             </li>
663                             <li>
664                                 <a href="#animate"><code>animate</code></a>
665                             </li>
666                             <li>
667                                 <a href="#getBBox"><code>getBBox</code></a>
668                             </li>
669                             <li>
670                                 <a href="#toFront"><code>toFront</code></a>
671                             </li>
672                             <li>
673                                 <a href="#toBack"><code>toBack</code></a>
674                             </li>
675                             <li>
676                                 <a href="#insertBefore"><code>insertBefore</code></a>
677                             </li>
678                             <li>
679                                 <a href="#insertAfter"><code>insertAfter</code></a>
680                             </li>
681                             <li>
682                                 <a href="#raphael"><code>raphael</code></a>
683                             </li>
684                             <li>
685                                 <a href="#setSize"><code>setSize</code></a>
686                             </li>
687                             <li>
688                                 <a href="#setWindow"><code>setWindow</code></a>
689                             </li>
690                             <li>
691                                 <a href="#getRGB"><code>getRGB</code></a>
692                             </li>
693                             <li>
694                                 <a href="#getColor"><code>getColor</code></a>
695                             </li>
696                             <li>
697                                 <a href="#getColor-reset"><code>getColor.reset</code></a>
698                             </li>
699                             <li>
700                                 <a href="#registerFont"><code>registerFont</code></a>
701                             </li>
702                             <li>
703                                 <a href="#getFont"><code>getFont</code></a>
704                             </li>
705                             <li>
706                                 <a href="#print"><code>print</code></a>
707                             </li>
708                             <li>
709                                 <a href="#circle"><code>circle</code></a>
710                             </li>
711                             <li>
712                                 <a href="#rect"><code>rect</code></a>
713                             </li>
714                             <li>
715                                 <a href="#ellipse"><code>ellipse</code></a>
716                             </li>
717                             <li>
718                                 <a href="#image"><code>image</code></a>
719                             </li>
720                             <li>
721                                 <a href="#set"><code>set</code></a>
722                             </li>
723                             <li>
724                                 <a href="#text"><code>text</code></a>
725                             </li>
726                             <li>
727                                 <a href="#path"><code>path</code></a>
728                             </li>
729                             <li>
730                                 <a href="#plugins-canvas">Adding your own methods to canvas</a>
731                             </li>
732                             <li>
733                                 <a href="#plugins-elements">Adding your own methods to elements</a>
734                             </li>
735                             <li>
736                                 <a href="#colour">Supported colour formats</a>
737                             </li>
738                             <li>
739                                 <a href="#safari">safari</a>
740                             </li>
741                             <li>
742                                 <a href="#ninja-mode">“Ninja Mode”</a>
743                             </li>
744                         </ul>
745                     </div>
746                     <div  id="footer">
747                         <h3 id="copyright">
748                             <a href="http://www.opensource.org/licenses/mit-license.php" title="MIT License" rel="license">Some Rights Reserved</a> by <a href="http://dmitry.baranovskiy.com/">Dmitry Baranovskiy</a>
749                         </h3>
750                         <h3 id="font">
751                             Font by <a href="http://www.exljbris.nl">Jos Buivenga</a> · Logo by <a href="http://wasabicube.com/">Wasabicube</a> ·
752                             Work at this project started as 20% time at <a href="http://www.atlassian.com/" title="Atlassian — Software to Track, Test &#38; Collaborate, from Enterprises to Open Source Projects.">Atlassian</a>
753                         </h3>
754                     </div>
755                 </div>
756             </div>
757         </div>
758         <script type="text/javascript">
759         var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
760         document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
761         </script>
762         <script type="text/javascript">
763         var pageTracker = _gat._getTracker("UA-616618-3");
764         pageTracker._trackPageview();
765         </script>
766         <script src="http://static.woopra.com/js/woopra.js" type="text/javascript" charset="utf-8"></script>
767     </body>
768 </html>