diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-26 14:15:55 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-26 14:15:55 +0100 |
commit | d64b964d21e1399b198e44555be68a12378053e7 (patch) | |
tree | 460fc3f518d061742083cdd9a5e0c77accc663ee | |
parent | ba63b0157f04d2aa11ff4f2e9ba5bbe3271b9086 (diff) | |
download | svg.js-d64b964d21e1399b198e44555be68a12378053e7.tar.gz svg.js-d64b964d21e1399b198e44555be68a12378053e7.zip |
Fix bug when converting black to cymk space
-rw-r--r-- | dist/svg.js | 8 | ||||
-rw-r--r-- | src/types/Color.js | 6 |
2 files changed, 13 insertions, 1 deletions
diff --git a/dist/svg.js b/dist/svg.js index 35335ed..1252dc0 100644 --- a/dist/svg.js +++ b/dist/svg.js @@ -6,7 +6,7 @@ * @copyright Wout Fierens <wout@mick-wout.com> * @license MIT * -* BUILT: Mon Nov 26 2018 14:01:22 GMT+0100 (GMT+01:00) +* BUILT: Mon Nov 26 2018 14:15:16 GMT+0100 (GMT+01:00) */; var SVG = (function () { 'use strict'; @@ -1452,6 +1452,12 @@ var SVG = (function () { var k = Math.min(1 - r, 1 - g, 1 - b); + + if (k === 1) { + // Catch the black case + return new Color(0, 0, 0, 1, 'cmyk'); + } + var c = (1 - r - k) / (1 - k); var m = (1 - g - k) / (1 - k); var y = (1 - b - k) / (1 - k); // Construct the new color diff --git a/src/types/Color.js b/src/types/Color.js index 3cd7dd0..0004251 100644 --- a/src/types/Color.js +++ b/src/types/Color.js @@ -313,6 +313,12 @@ export default class Color { // Get the cmyk values in an unbounded format const k = Math.min(1 - r, 1 - g, 1 - b) + + if (k === 1) { + // Catch the black case + return new Color(0, 0, 0, 1, 'cmyk') + } + const c = (1 - r - k) / (1 - k) const m = (1 - g - k) / (1 - k) const y = (1 - b - k) / (1 - k) |