diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2020-04-09 21:19:14 +1000 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2020-04-09 21:19:14 +1000 |
commit | 02cbd2998c3c36b88701ce83089df8947be1de9f (patch) | |
tree | 668e6cf5db5bfbdb37a774363757970c4cb655b0 /src/elements/Gradient.js | |
parent | 25461a4733d7dcfc6f8127e8419f5eddbbb4b4aa (diff) | |
download | svg.js-02cbd2998c3c36b88701ce83089df8947be1de9f.tar.gz svg.js-02cbd2998c3c36b88701ce83089df8947be1de9f.zip |
added test for Gradient
Diffstat (limited to 'src/elements/Gradient.js')
-rw-r--r-- | src/elements/Gradient.js | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/src/elements/Gradient.js b/src/elements/Gradient.js index d5ae8b7..4e09cbd 100644 --- a/src/elements/Gradient.js +++ b/src/elements/Gradient.js @@ -7,7 +7,6 @@ import { import { registerMethods } from '../utils/methods.js' import Box from '../types/Box.js' import Container from './Container.js' -import Stop from './Stop.js' import baseFind from '../modules/core/selector.js' import * as gradiented from '../modules/core/gradiented.js' @@ -19,9 +18,23 @@ export default class Gradient extends Container { ) } - // Add a color stop - stop (offset, color, opacity) { - return this.put(new Stop()).update(offset, color, opacity) + // custom attr to handle transform + attr (a, b, c) { + if (a === 'transform') a = 'gradientTransform' + return super.attr(a, b, c) + } + + bbox () { + return new Box() + } + + targets () { + return baseFind('svg [fill*="' + this.id() + '"]') + } + + // Alias string conversion to fill + toString () { + return this.url() } // Update gradient @@ -39,26 +52,7 @@ export default class Gradient extends Container { // Return the fill id url () { - return 'url(#' + this.id() + ')' - } - - // Alias string convertion to fill - toString () { - return this.url() - } - - // custom attr to handle transform - attr (a, b, c) { - if (a === 'transform') a = 'gradientTransform' - return super.attr(a, b, c) - } - - targets () { - return baseFind('svg [fill*="' + this.id() + '"]') - } - - bbox () { - return new Box() + return 'url("#' + this.id() + '")' } } |