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