Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><code>fn</code> is used for <strong><a href="http://raphaeljs.com/reference.html#plugins-canvas" rel="nofollow noreferrer">adding your own methods to the canvas</a></strong>. </p> <p>Any methods you add to <code>fn</code> will work on the canvas. This is in contrast to methods that would work on <strong><a href="http://raphaeljs.com/reference.html#plugins-elements" rel="nofollow noreferrer">for example an element</a></strong> ( for which you would use <code>el</code>).</p> <p>Since extending the <code>fn</code> object will act on the canvas, you must add your custom methods <strong>before creating your Raphael instance</strong> (this is not true if you are extending the <code>el</code> of an element).</p> <p>For example, from the documentation:</p> <pre><code> // Extend Raphael fn object by adding methods to it: Raphael.fn.arrow = function (x1, y1, x2, y2, size) { return this.path( ... ); }; // or add namespaces to it: Raphael.fn.mystuff = { arrow: function () {…}, star: function () {…}, // etc… }; // Now when you create a Raphael instance, your custom // methods are available. var paper = Raphael(10, 10, 630, 480); // Using custom methods: paper.arrow(10, 10, 30, 30, 5).attr({fill: "#f00"}); // Using name spaced custom methods paper.mystuff.arrow(); paper.mystuff.star(); </code></pre> <hr> <p><strong>Update (thanks AleksandraKos):</strong></p> <p>Note that, <a href="http://raphaeljs.com/reference.html#Raphael.fn" rel="nofollow noreferrer">namespaced plugins was removed in Raphael 2.0</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload