From 44be0ceecb2ba43ab45d7fefa299179ae76303fa Mon Sep 17 00:00:00 2001 From: wout Date: Sun, 30 Dec 2012 11:20:41 +0100 Subject: Updated REAME --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 272cce9..8977c1a 100644 --- a/README.md +++ b/README.md @@ -389,6 +389,7 @@ _This functionality requires the gradient.js module which is included in the def ## Extending functionality Svg.js has a modular structure. It is very easy to add you own methods at different levels. Let's say we want to add a method to all shape types then we would add our method to SVG.Shape: + ```javascript SVG.extend(SVG.Shape, { @@ -398,23 +399,27 @@ SVG.extend(SVG.Shape, { }); ``` -Now all shapes will have the paintRed method available. Say we want to have the paintRed method on a circle apply a slightly different color: + +Now all shapes will have the paintRed method available. Say we want to have the paintRed method on an ellipse apply a slightly different color: + ```javascript -SVG.extend(SVG.Circle, { +SVG.extend(SVG.Ellipse, { paintRed: function() { return this.fill({ color: 'orangered' }); } }); + ``` -The complete inheritance stack for `SVG.Circle` is: +The complete inheritance stack for `SVG.Ellipse` is: -_SVG.Circle < SVG.Shape < SVG.Element_ +_SVG.Ellipse < SVG.Shape < SVG.Element_ The SVG document can be extended by using: ```javascript + SVG.extend(SVG.Doc, { paintAllPink: function() { -- cgit v1.2.3