summaryrefslogtreecommitdiffstats
path: root/src/gradient.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-03-09 22:28:47 +0100
committerwout <wout@impinc.co.uk>2013-03-09 22:28:47 +0100
commit6c6c82ed59533f44f8754b69d47e3b11cd6dd129 (patch)
treeadaef53d8970acb228fe14d490c532f1baabbb13 /src/gradient.js
parent16c4a146ee97fa43e0c456fe801490351e551e96 (diff)
downloadsvg.js-6c6c82ed59533f44f8754b69d47e3b11cd6dd129.tar.gz
svg.js-6c6c82ed59533f44f8754b69d47e3b11cd6dd129.zip
Bumped to v0.9, added better style management, text support and extended animation functionality0.10
Diffstat (limited to 'src/gradient.js')
-rw-r--r--src/gradient.js32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/gradient.js b/src/gradient.js
index 73975c5..4c30b43 100644
--- a/src/gradient.js
+++ b/src/gradient.js
@@ -15,25 +15,25 @@ SVG.extend(SVG.Gradient, {
return this.type == 'radial' ?
this.attr({ fx: x + '%', fy: y + '%' }) :
this.attr({ x1: x + '%', y1: y + '%' })
- },
+ }
// To position
- to: function(x, y) {
+, to: function(x, y) {
return this.type == 'radial' ?
this.attr({ cx: x + '%', cy: y + '%' }) :
this.attr({ x2: x + '%', y2: y + '%' })
- },
+ }
// Radius for radial gradient
- radius: function(radius) {
+, radius: function(radius) {
return this.type == 'radial' ?
this.attr({ r: radius + '%' }) :
this
- },
+ }
// Add a color stop
- at: function(stop) {
+, at: function(stop) {
return this.put(new SVG.Stop(stop))
- },
+ }
// Update gradient
- update: function(block) {
+, update: function(block) {
/* remove all stops */
while (this.node.hasChildNodes())
this.node.removeChild(this.node.lastChild)
@@ -42,9 +42,9 @@ SVG.extend(SVG.Gradient, {
block(this)
return this
- },
+ }
// Return the fill id
- fill: function() {
+, fill: function() {
return 'url(#' + this.attr('id') + ')'
}
@@ -81,20 +81,16 @@ SVG.extend(SVG.Stop, {
/* add color stops */
update: function(o) {
- var index,
- style = '',
- attr = ['opacity', 'color']
+ var index
+ , 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]] + ';'
+ this.style('stop-' + attr[index], o[attr[index]])
/* set attributes */
- return this.attr({
- offset: (o.offset != null ? o.offset : this.attrs.offset || 0) + '%',
- style: style
- })
+ return this.attr('offset', (o.offset != null ? o.offset : this.attrs.offset || 0) + '%')
}
})