summaryrefslogtreecommitdiffstats
path: root/dist/svg.js
diff options
context:
space:
mode:
Diffstat (limited to 'dist/svg.js')
-rw-r--r--dist/svg.js83
1 files changed, 29 insertions, 54 deletions
diff --git a/dist/svg.js b/dist/svg.js
index 1fec3d5..215567b 100644
--- a/dist/svg.js
+++ b/dist/svg.js
@@ -1,4 +1,4 @@
-/* svg.js v0.1-65-geb58a52 - svg container element fx event group arrange defs mask gradient doc shape wrap rect ellipse poly path image text nested sugar - svgjs.com/license */
+/* svg.js v0.1-66-g6175f1a - svg container element fx event group arrange defs mask gradient doc shape wrap rect ellipse poly path image text nested sugar - svgjs.com/license */
(function() {
this.svg = function(element) {
@@ -161,15 +161,15 @@
'fill-opacity': 1,
'stroke-opacity': 1,
'stroke-width': 0,
- x: 0,
- y: 0,
- cx: 0,
- cy: 0,
- width: 0,
- height: 0,
- r: 0,
- rx: 0,
- ry: 0
+ x: 0,
+ y: 0,
+ cx: 0,
+ cy: 0,
+ width: 0,
+ height: 0,
+ r: 0,
+ rx: 0,
+ ry: 0
};
/* initialize transformation store with defaults */
@@ -1241,41 +1241,33 @@
// Include the container object
SVG.extend(SVG.Nested, SVG.Container);
- var _strokeAttr = ['width', 'opacity', 'linecap', 'linejoin', 'miterlimit', 'dasharray', 'dashoffset'],
- _fillAttr = ['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;
+ };
- SVG.extend(SVG.Shape, {
+ /* Add sugar for fill and stroke */
+ ['fill', 'stroke'].forEach(function(method) {
// Set fill color and opacity
- fill: function(fill) {
+ SVG.Shape.prototype[method] = function(o) {
var index;
- /* set fill color if not null */
- if (fill.color != null)
- this.attr('fill', fill.color);
-
- /* set all attributes from _fillAttr list with prependes 'fill-' if not null */
- for (index = _fillAttr.length - 1; index >= 0; index--)
- if (fill[_fillAttr[index]] != null)
- this.attr('fill-' + _fillAttr[index], fill[_fillAttr[index]]);
-
- return this;
- },
- // Set stroke color and opacity
- stroke: function(stroke) {
- var index;
+ if (typeof o == 'string')
+ this.attr(method, o);
- // set stroke color if not null
- if (stroke.color)
- this.attr('stroke', stroke.color);
-
- // set all attributes from _strokeAttr list with prependes 'stroke-' if not null
- for (index = _strokeAttr.length - 1; index >= 0; index--)
- if (stroke[_strokeAttr[index]] != null)
- this.attr('stroke-' + _strokeAttr[index], stroke[_strokeAttr[index]]);
+ 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]]);
return this;
- }
+ };
});
@@ -1328,23 +1320,6 @@
if (SVG.FX) {
- /* Add sugar for fill and stroke */
- ['fill', 'stroke'].forEach(function(method) {
- SVG.FX.prototype[method] = function(o) {
- var attr, key;
-
- for (key in o) {
- attr = key == 'color' ? method : method + '-' + key;
- this.attrs[attr] = {
- from: this.target.attrs[attr],
- to: o[key]
- };
- };
-
- return this;
- };
- });
-
SVG.extend(SVG.FX, {
// Rotation
rotate: function(angle) {