diff options
author | wout <wout@impinc.co.uk> | 2012-12-30 11:20:41 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2012-12-30 11:20:41 +0100 |
commit | 44be0ceecb2ba43ab45d7fefa299179ae76303fa (patch) | |
tree | 00bdc9085c891d667e248f89e674870f2dc15c84 | |
parent | 68367e494fcab754ae4833e64804a824032cf31c (diff) | |
download | svg.js-44be0ceecb2ba43ab45d7fefa299179ae76303fa.tar.gz svg.js-44be0ceecb2ba43ab45d7fefa299179ae76303fa.zip |
Updated REAME
-rw-r--r-- | README.md | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -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() { |