From f0dc4d5ee03add261242743aa583c19d918f317c Mon Sep 17 00:00:00 2001 From: wout Date: Fri, 1 Aug 2014 20:40:49 +0200 Subject: Added SVG.Bare for creation of non-described elements --- README.md | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index bde474f..b1830c9 100755 --- a/README.md +++ b/README.md @@ -798,10 +798,40 @@ symbol.rect(100, 100).fill('#f09') var use = draw.use(symbol).move(200, 200) ``` -__`returns`: `SVG.Symbol`__ +__`returns`: `SVG.Bare`__ -_Javascript inheritance stack: `SVG.Symbol` < `SVG.Container` < `SVG.Element`_ +_Javascript inheritance stack: `SVG.Bare` < `SVG.Element` [with a shallow inheritance from `SVG.Parent`]_ +## Bare +For all SVG elements that are not described by SVG.js, the `SVG.Bare` class comes in handy. This class inherits directly from `SVG.Element` and makes it possible to add custom methods in a separate namespace. + +### element() +the `SVG.Bare` class can be instantiated with the `element()` method on any parent element: + +```javascript +var element = draw.element('title') +``` +The stirng value passed as the first argument is the node name that should be generated. + +Additionally the class name can be passed as the second argument from which the element should inherit: + +```javascript +var element = draw.element('symbol', SVG.Parent) +``` + +This gives you as the user a lot of power. But remember, with great power comes great responsibility. + +__`returns`: `SVG.Bare`__ + +### words() +The `SVG.Bare` instance carries an additional method to add plain text: + +```javascript +var element = draw.element('title').words('This is a title.') +//-> This is a title. +``` + +__`returns`: `itself`__ ## Referencing elements -- cgit v1.2.3