diff options
author | wout <wout@impinc.co.uk> | 2013-02-20 19:10:03 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2013-02-20 19:10:03 +0100 |
commit | ae878fd63077d4c95f2de9053a6f0951b55239eb (patch) | |
tree | 5dba7bd42a8b5702faeb6cc12d2b4d4099841e51 /src/sugar.js | |
parent | 5020240e4029a61a9620f21d7be4d9764e7723d1 (diff) | |
download | svg.js-ae878fd63077d4c95f2de9053a6f0951b55239eb.tar.gz svg.js-ae878fd63077d4c95f2de9053a6f0951b55239eb.zip |
Created separate classes for SVG.ViewBox anSVG.BBox0.6
Diffstat (limited to 'src/sugar.js')
-rw-r--r-- | src/sugar.js | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/sugar.js b/src/sugar.js index c8b71fb..e076491 100644 --- a/src/sugar.js +++ b/src/sugar.js @@ -1,65 +1,65 @@ // Define list of available attributes for stroke and fill -SVG._stroke = ['color', 'width', 'opacity', 'linecap', 'linejoin', 'miterlimit', 'dasharray', 'dashoffset']; -SVG._fill = ['color', 'opacity', 'rule']; +SVG._stroke = ['color', 'width', 'opacity', 'linecap', 'linejoin', 'miterlimit', 'dasharray', 'dashoffset'] +SVG._fill = ['color', 'opacity', 'rule'] // Prepend correct color prefix var _colorPrefix = function(type, attr) { - return attr == 'color' ? type : type + '-' + attr; -}; + return attr == 'color' ? type : type + '-' + attr +} /* Add sugar for fill and stroke */ -['fill', 'stroke'].forEach(function(method) { +;['fill', 'stroke'].forEach(function(method) { // Set fill color and opacity SVG.Shape.prototype[method] = function(o) { - var index; + var indexOf if (typeof o == 'string') - this.attr(method, o); + this.attr(method, o) else /* set all attributes from _fillAttr and _strokeAttr list */ for (index = SVG['_' + method].length - 1; index >= 0; index--) if (o[SVG['_' + method][index]] != null) - this.attr(_colorPrefix(method, SVG['_' + method][index]), o[SVG['_' + method][index]]); + this.attr(_colorPrefix(method, SVG['_' + method][index]), o[SVG['_' + method][index]]) - return this; - }; + return this + } -}); +}) -[SVG.Element, SVG.FX].forEach(function(module) { +;[SVG.Element, SVG.FX].forEach(function(module) { if (module) { SVG.extend(module, { // Rotation rotate: function(angle) { return this.transform({ rotation: angle || 0 - }); + }) }, // Skew skew: function(x, y) { return this.transform({ skewX: x || 0, skewY: y || 0 - }); + }) }, // Scale scale: function(x, y) { return this.transform({ scaleX: x, scaleY: y == null ? x : y - }); + }) }, // Opacity opacity: function(value) { - return this.attr('opacity', value); + return this.attr('opacity', value) } - }); + }) } -}); +}) if (SVG.G) { SVG.extend(SVG.G, { @@ -68,17 +68,17 @@ if (SVG.G) { return this.transform({ x: x, y: y - }); + }) } - }); + }) } if (SVG.Text) { SVG.extend(SVG.Text, { // Set font font: function(o) { - var key, attr = {}; + var key, attr = {} for (key in o) key == 'leading' ? @@ -87,11 +87,11 @@ if (SVG.Text) { attr['text-anchor'] = o[key] : _styleAttr.indexOf(key) > -1 ? attr['font-'+ key] = o[key] : - void 0; + void 0 - return this.attr(attr).text(this.content); + return this.attr(attr).text(this.content) } - }); + }) } |