Fixed eslint issues

This commit is contained in:
Tomas Korcak 2015-08-14 22:53:46 +02:00
parent 2a8011df34
commit c85f591f93
3 changed files with 35 additions and 38 deletions

View File

@ -21,7 +21,7 @@ class Color {
this.__state = interpret.apply(this, arguments);
if (this.__state === false) {
throw 'Failed to interpret color arguments';
throw new Error('Failed to interpret color arguments');
}
this.__state.a = this.__state.a || 1;
@ -42,12 +42,12 @@ Color.recalculateRGB = function(color, component, componentHexIndex) {
} else if (color.__state.space === 'HSV') {
common.extend(color.__state, math.hsv_to_rgb(color.__state.h, color.__state.s, color.__state.v));
} else {
throw 'Corrupted color state';
throw new Error('Corrupted color state');
}
};
Color.recalculateHSV = function(color) {
var result = math.rgb_to_hsv(color.r, color.g, color.b);
const result = math.rgb_to_hsv(color.r, color.g, color.b);
common.extend(color.__state,
{
@ -131,7 +131,6 @@ function defineHSVComponent(target, component) {
Color.recalculateHSV(this);
return this.__state[component];
},
set: function(v) {

View File

@ -11,19 +11,18 @@
* http://www.apache.org/licenses/LICENSE-2.0
*/
var tmpComponent;
var ColorMath = {
let tmpComponent;
const ColorMath = {
hsv_to_rgb: function(h, s, v) {
const hi = Math.floor(h / 60) % 6;
var hi = Math.floor(h / 60) % 6;
const f = h / 60 - Math.floor(h / 60);
const p = v * (1.0 - s);
const q = v * (1.0 - (f * s));
const t = v * (1.0 - ((1.0 - f) * s));
var f = h / 60 - Math.floor(h / 60);
var p = v * (1.0 - s);
var q = v * (1.0 - (f * s));
var t = v * (1.0 - ((1.0 - f) * s));
var c = [
const c = [
[v, t, p],
[q, v, p],
[p, v, t],
@ -37,17 +36,16 @@ var ColorMath = {
g: c[1] * 255,
b: c[2] * 255
};
},
rgb_to_hsv: function(r, g, b) {
const min = Math.min(r, g, b);
const max = Math.max(r, g, b);
const delta = max - min;
let h;
let s;
var min = Math.min(r, g, b),
max = Math.max(r, g, b),
delta = max - min,
h, s;
if (max != 0) {
if (max !== 0) {
s = delta / max;
} else {
return {
@ -57,9 +55,9 @@ var ColorMath = {
};
}
if (r == max) {
if (r === max) {
h = (g - b) / delta;
} else if (g == max) {
} else if (g === max) {
h = 2 + (b - r) / delta;
} else {
h = 4 + (r - g) / delta;
@ -77,7 +75,7 @@ var ColorMath = {
},
rgb_to_hex: function(r, g, b) {
var hex = this.hex_with_component(0, 2, r);
let hex = this.hex_with_component(0, 2, r);
hex = this.hex_with_component(hex, 1, g);
hex = this.hex_with_component(hex, 0, b);
return hex;
@ -90,6 +88,6 @@ var ColorMath = {
hex_with_component: function(hex, componentIndex, value) {
return value << (tmpComponent = componentIndex * 8) | (hex & ~(0xFF << tmpComponent));
}
}
};
export default ColorMath;

View File

@ -23,4 +23,4 @@ export default function(color) {
}
return 'rgba(' + Math.round(color.r) + ',' + Math.round(color.g) + ',' + Math.round(color.b) + ',' + color.a + ')';
};
}