From d64b964d21e1399b198e44555be68a12378053e7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ulrich-Matthias=20Sch=C3=A4fer?= Date: Mon, 26 Nov 2018 14:15:55 +0100 Subject: [PATCH] Fix bug when converting black to cymk space --- dist/svg.js | 8 +++++++- src/types/Color.js | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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 * @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) -- 2.39.5