make Ox.rgb always return integers

This commit is contained in:
rolux 2012-06-24 17:41:27 +02:00
parent fa84921333
commit d29bc5569b
4 changed files with 9 additions and 25 deletions

View file

@ -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 = $('<div>')
.addClass(

View file

@ -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;

View file

@ -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;

View file

@ -97,7 +97,7 @@ Ox.rgb = function(hsl) {
});
}
return rgb.map(function(value) {
return value * 255;
return Math.round(value * 255);
});
};