From d29bc5569bfd3eeb3a035b9c5a113183deb55d8c Mon Sep 17 00:00:00 2001 From: rolux Date: Sun, 24 Jun 2012 17:41:27 +0200 Subject: [PATCH] make Ox.rgb always return integers --- source/Ox.UI/js/Core/Theme.js | 22 ++++++---------------- source/Ox.UI/js/Form/ColorInput.js | 4 +--- source/Ox.UI/js/Form/ColorPicker.js | 6 +----- source/Ox/js/Color.js | 2 +- 4 files changed, 9 insertions(+), 25 deletions(-) diff --git a/source/Ox.UI/js/Core/Theme.js b/source/Ox.UI/js/Core/Theme.js index 221901c4..981db4f5 100644 --- a/source/Ox.UI/js/Core/Theme.js +++ b/source/Ox.UI/js/Core/Theme.js @@ -29,21 +29,13 @@ Ox.Theme = (function() { function renderElement(value, type) { var $element, background, color, lightness = that[getTheme()].lightness; if (type == 'hue') { - background = Ox.rgb(value, 1, lightness.background).map(function(value) { - return Math.round(value); - }); - color = Ox.rgb(value, 1, lightness.color).map(function(value) { - return Math.round(value); - }); + background = Ox.rgb(value, 1, lightness.background); + color = Ox.rgb(value, 1, lightness.color); } else if (type == 'saturation') { background = Ox.range(7).map(function(i) { - return Ox.rgb(i * 60, value, lightness.background).map(function(value) { - return Math.round(value); - }); - }); - color = Ox.rgb(0, 0, lightness.color).map(function(value) { - return Math.round(value); + return Ox.rgb(i * 60, value, lightness.background); }); + color = Ox.rgb(0, 0, lightness.color); } else if (type == 'lightness') { background = Ox.range(3).map(function() { return Math.round(value * 255); @@ -54,12 +46,10 @@ Ox.Theme = (function() { } else if (type == 'gradient') { background = Ox.range(2).map(function(i) { return Ox.rgb(value, 1, lightness.background).map(function(value) { - return Math.round(value + (i == 0 ? 16 : -16)); + return value + (i == 0 ? 16 : -16); }); }); - color = Ox.rgb(value, 1, lightness.color).map(function(value) { - return Math.round(value); - }); + color = Ox.rgb(value, 1, lightness.color); } $element = $('
') .addClass( diff --git a/source/Ox.UI/js/Form/ColorInput.js b/source/Ox.UI/js/Form/ColorInput.js index 78028802..78c9e3ef 100644 --- a/source/Ox.UI/js/Form/ColorInput.js +++ b/source/Ox.UI/js/Form/ColorInput.js @@ -80,9 +80,7 @@ Ox.ColorInput = function(options, self) { function getRGB() { return self.options.mode == 'rgb' ? self.options.value - : Ox.rgb(self.options.value).map(function(value) { - return Math.round(value); - }); + : Ox.rgb(self.options.value); } return that; diff --git a/source/Ox.UI/js/Form/ColorPicker.js b/source/Ox.UI/js/Form/ColorPicker.js index a08fd948..fcb7a6b1 100644 --- a/source/Ox.UI/js/Form/ColorPicker.js +++ b/source/Ox.UI/js/Form/ColorPicker.js @@ -109,11 +109,7 @@ Ox.ColorPicker = function(options, self) { } function getRGB(values) { - return self.options.mode == 'rgb' - ? values - : Ox.rgb(values).map(function(value) { - return Math.round(value); - }); + return self.options.mode == 'rgb' ? values : Ox.rgb(values); } return that; diff --git a/source/Ox/js/Color.js b/source/Ox/js/Color.js index cb8c5692..527a1cd0 100644 --- a/source/Ox/js/Color.js +++ b/source/Ox/js/Color.js @@ -97,7 +97,7 @@ Ox.rgb = function(hsl) { }); } return rgb.map(function(value) { - return value * 255; + return Math.round(value * 255); }); };