From 36b90395b85d6859dd78af9eb71c3df343e24841 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 26 Aug 2014 19:10:56 -0400 Subject: catch divide-by-zero error in xyz2hunterlab function --- public/assets/javascripts/ui/editor/LightControl.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'public/assets/javascripts') diff --git a/public/assets/javascripts/ui/editor/LightControl.js b/public/assets/javascripts/ui/editor/LightControl.js index b1c5b85..1bd660e 100644 --- a/public/assets/javascripts/ui/editor/LightControl.js +++ b/public/assets/javascripts/ui/editor/LightControl.js @@ -170,6 +170,7 @@ var LabColorPicker = function (parent, w, h) { var y = mix( norm(Lab[2], b_range[0], b_range[1]), 0, hh ) // move the cursor this.setLab(Lab) + console.log(rgba) return Lab } this.paint = function() { @@ -245,13 +246,11 @@ var LabColorPicker = function (parent, w, h) { } function xyz2hunterlab (XYZ) { var X = XYZ[0] - var Y = XYZ[1] + var Y = XYZ[1] || 1e-6 // otherwise divide-by-zero error when converting rgb(0,0,0) var Z = XYZ[2] var L = 10 * sqrt( Y ) var a = 17.5 * ( ( ( 1.02 * X ) - Y ) / sqrt( Y ) ) var b = 7 * ( ( Y - ( 0.847 * Z ) ) / sqrt( Y ) ) return [L,a,b] } - - // this.paint(val) } -- cgit v1.2.3-70-g09d2