summaryrefslogtreecommitdiffstats
path: root/src/gradient.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/gradient.js')
-rw-r--r--src/gradient.js56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/gradient.js b/src/gradient.js
index 07bb748..f3ba85c 100644
--- a/src/gradient.js
+++ b/src/gradient.js
@@ -1,15 +1,15 @@
-SVG.Gradient = function Gradient(type) {
- this.constructor.call(this, SVG.create(type + 'Gradient'));
+SVG.Gradient = function(type) {
+ this.constructor.call(this, SVG.create(type + 'Gradient'))
/* set unique id */
- this.attr('id', (this.id = 'svgjs_element_' + (SVG.did++)));
+ this.attr('id', (this.id = 'svgjs_element_' + (SVG.did++)))
/* store type */
- this.type = type;
-};
+ this.type = type
+}
// Inherit from SVG.Container
-SVG.Gradient.prototype = new SVG.Container();
+SVG.Gradient.prototype = new SVG.Container
//
SVG.extend(SVG.Gradient, {
@@ -17,67 +17,67 @@ SVG.extend(SVG.Gradient, {
from: function(x, y) {
return this.type == 'radial' ?
this.attr({ fx: x + '%', fy: y + '%' }) :
- this.attr({ x1: x + '%', y1: y + '%' });
+ this.attr({ x1: x + '%', y1: y + '%' })
},
// To position
to: function(x, y) {
return this.type == 'radial' ?
this.attr({ cx: x + '%', cy: y + '%' }) :
- this.attr({ x2: x + '%', y2: y + '%' });
+ this.attr({ x2: x + '%', y2: y + '%' })
},
// Radius for radial gradient
radius: function(radius) {
return this.type == 'radial' ?
this.attr({ r: radius + '%' }) :
- this;
+ this
},
// Add a color stop
at: function(stop) {
- return this.put(new SVG.Stop(stop));
+ return this.put(new SVG.Stop(stop))
},
// Update gradient
update: function(block) {
/* remove all stops */
while (this.node.hasChildNodes())
- this.node.removeChild(this.node.lastChild);
+ this.node.removeChild(this.node.lastChild)
/* invoke passed block */
- block(this);
+ block(this)
- return this;
+ return this
},
// Return the fill id
fill: function() {
- return 'url(#' + this.id + ')';
+ return 'url(#' + this.id + ')'
}
-});
+})
//
SVG.extend(SVG.Defs, {
/* define gradient */
gradient: function(type, block) {
- var element = this.put(new SVG.Gradient(type));
+ var element = this.put(new SVG.Gradient(type))
/* invoke passed block */
- block(element);
+ block(element)
- return element;
+ return element
}
-});
+})
-SVG.Stop = function Stop(stop) {
- this.constructor.call(this, SVG.create('stop'));
+SVG.Stop = function(stop) {
+ this.constructor.call(this, SVG.create('stop'))
/* immediatelly build stop */
- this.update(stop);
-};
+ this.update(stop)
+}
// Inherit from SVG.Element
-SVG.Stop.prototype = new SVG.Element();
+SVG.Stop.prototype = new SVG.Element()
//
SVG.extend(SVG.Stop, {
@@ -86,19 +86,19 @@ SVG.extend(SVG.Stop, {
update: function(o) {
var index,
style = '',
- attr = ['opacity', 'color'];
+ attr = ['opacity', 'color']
/* build style attribute */
for (index = attr.length - 1; index >= 0; index--)
if (o[attr[index]] != null)
- style += 'stop-' + attr[index] + ':' + o[attr[index]] + ';';
+ style += 'stop-' + attr[index] + ':' + o[attr[index]] + ';'
/* set attributes */
return this.attr({
offset: (o.offset != null ? o.offset : this.attrs.offset || 0) + '%',
style: style
- });
+ })
}
-});
+})