diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-05-15 10:58:32 +0200 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-05-15 10:58:32 +0200 |
commit | 601ab0e2494a91bc392fe89046a8166e098ff0d7 (patch) | |
tree | 5f3cbc2dacf68c770711b24afc6452e6e5967404 /src/color.js | |
parent | 685d53295dd005c6f513b6123d8cd3fb3e671c8a (diff) | |
download | svg.js-601ab0e2494a91bc392fe89046a8166e098ff0d7.tar.gz svg.js-601ab0e2494a91bc392fe89046a8166e098ff0d7.zip |
fixed morphing. Changed easing function so that it can handle strings
- error in Matrix constructor which ignores translateX (and more?)
- generelized all morphable objects so that they behave logical
- SVG.Morphable can handle all datatypes now
Diffstat (limited to 'src/color.js')
-rw-r--r-- | src/color.js | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/color.js b/src/color.js index 9fc6f76..cb1500a 100644 --- a/src/color.js +++ b/src/color.js @@ -30,7 +30,7 @@ SVG.lab('rgb(100, 100, 100)') */ // Module for color convertions -SVG.Color = function (color) { +SVG.Color = function (color, g, b) { var match // initialize defaults @@ -59,10 +59,18 @@ SVG.Color = function (color) { this.g = parseInt(match[2], 16) this.b = parseInt(match[3], 16) } + } else if (Array.isArray(color)) { + this.r = color[0] + this.g = color[1] + this.b = color[2] } else if (typeof color === 'object') { this.r = color.r this.g = color.g this.b = color.b + } else if(arguments.length == 3) { + this.r = color + this.g = g + this.b = b } } @@ -75,14 +83,14 @@ SVG.extend(SVG.Color, { return [this.r, this.g, this.b] }, fromArray: function (a) { - return new SVG.Color(a[0], a[1], a[2]) + return new SVG.Color(a) }, // Build hex value toHex: function () { return '#' + - compToHex(this.r) + - compToHex(this.g) + - compToHex(this.b) + compToHex(Math.round(this.r)) + + compToHex(Math.round(this.g)) + + compToHex(Math.round(this.b)) }, // Build rgb value toRgb: function () { |