Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var Color = function(cssString) {
this.values = {
rgb: [0, 0, 0],
hsl: [0, 0, 0],
hsv: [0, 0, 0],
cmyk: [0, 0, 0, 0],
alpha: 1
}
// parse Color() argument
if (typeof cssString == "string") {
var vals = string.getRgba(cssString);
if (vals) {
this.setValues("rgb", vals);
}
else if(vals = string.getHsla(cssString)) {
this.setValues("hsl", vals);
}
}
else if (typeof cssString == "object") {
var vals = cssString;
if(vals["r"] !== undefined || vals["red"] !== undefined) {
this.setValues("rgb", vals)
}
else if(vals["l"] !== undefined || vals["lightness"] !== undefined) {
this.setValues("hsl", vals)
}
else if(vals["v"] !== undefined || vals["value"] !== undefined) {
this.setValues("hsv", vals)
}
else if(vals["c"] !== undefined || vals["cyan"] !== undefined) {
this.setValues("cmyk", vals)
var Color = function(cssString) {
this.values = {
rgb: [0, 0, 0],
hsl: [0, 0, 0],
hsv: [0, 0, 0],
cmyk: [0, 0, 0, 0],
alpha: 1
}
// parse Color() argument
if (typeof cssString == "string") {
var vals = string.getRgba(cssString);
if (vals) {
this.setValues("rgb", vals);
}
else if(vals = string.getHsla(cssString)) {
this.setValues("hsl", vals);
}
}
else if (typeof cssString == "object") {
var vals = cssString;
if(vals["r"] !== undefined || vals["red"] !== undefined) {
this.setValues("rgb", vals)
}
else if(vals["l"] !== undefined || vals["lightness"] !== undefined) {
this.setValues("hsl", vals)
}
else if(vals["v"] !== undefined || vals["value"] !== undefined) {
this.setValues("hsv", vals)
}
else if(vals["c"] !== undefined || vals["cyan"] !== undefined) {
this.setValues("cmyk", vals)
this.values = {
rgb: [0, 0, 0],
hsl: [0, 0, 0],
hsv: [0, 0, 0],
hwb: [0, 0, 0],
cmyk: [0, 0, 0, 0],
alpha: 1
}
// parse Color() argument
if (typeof obj == "string") {
var vals = string.getRgba(obj);
if (vals) {
this.setValues("rgb", vals);
}
else if(vals = string.getHsla(obj)) {
this.setValues("hsl", vals);
}
else if(vals = string.getHwb(obj)) {
this.setValues("hwb", vals);
}
else {
throw new Error("Unable to parse color from string \"" + obj + "\"");
}
}
else if (typeof obj == "object") {
var vals = obj;
if(vals["r"] !== undefined || vals["red"] !== undefined) {
this.setValues("rgb", vals)
}
else if(vals["l"] !== undefined || vals["lightness"] !== undefined) {
this.setValues("hsl", vals)
values[sname] = convert[space][sname](values[space])
}
// cap values
for (var i = 0; i < sname.length; i++) {
values[sname][i] = Math.round(Math.max(0, Math.min(maxes[sname][i], values[sname][i])));
}
}
}
// parse Color() argument
if (typeof cssString == "string") {
var vals = string.getRgba(cssString);
if (vals) {
setValues("rgb", vals);
}
else if(vals = string.getHsla(cssString)) {
setValues("hsl", vals);
}
}
else if (typeof cssString == "object") {
var vals = cssString;
if(vals["r"] !== undefined || vals["red"] !== undefined) {
setValues("rgb", vals)
}
else if(vals["l"] !== undefined || vals["lightness"] !== undefined) {
setValues("hsl", vals)
}
else if(vals["v"] !== undefined || vals["value"] !== undefined) {
setValues("hsv", vals)
}
else if(vals["c"] !== undefined || vals["cyan"] !== undefined) {
setValues("cmyk", vals)
this.values = {
rgb: [0, 0, 0],
hsl: [0, 0, 0],
hsv: [0, 0, 0],
hwb: [0, 0, 0],
cmyk: [0, 0, 0, 0],
alpha: 1
};
// parse Color() argument
var vals;
if (typeof obj === 'string') {
vals = string.getRgba(obj);
if (vals) {
this.setValues('rgb', vals);
} else if (vals = string.getHsla(obj)) {
this.setValues('hsl', vals);
} else if (vals = string.getHwb(obj)) {
this.setValues('hwb', vals);
} else {
throw new Error('Unable to parse color from string "' + obj + '"');
}
} else if (typeof obj === 'object') {
vals = obj;
if (vals.r !== undefined || vals.red !== undefined) {
this.setValues('rgb', vals);
} else if (vals.l !== undefined || vals.lightness !== undefined) {
this.setValues('hsl', vals);
} else if (vals.v !== undefined || vals.value !== undefined) {
this.setValues('hsv', vals);
} else if (vals.w !== undefined || vals.whiteness !== undefined) {
this.setValues('hwb', vals);
this.values = {
rgb: [0, 0, 0],
hsl: [0, 0, 0],
hsv: [0, 0, 0],
hwb: [0, 0, 0],
cmyk: [0, 0, 0, 0],
alpha: 1
};
// parse Color() argument
var vals;
if (typeof obj === 'string') {
vals = string.getRgba(obj);
if (vals) {
this.setValues('rgb', vals);
} else if (vals = string.getHsla(obj)) {
this.setValues('hsl', vals);
} else if (vals = string.getHwb(obj)) {
this.setValues('hwb', vals);
} else {
throw new Error('Unable to parse color from string "' + obj + '"');
}
} else if (typeof obj === 'object') {
vals = obj;
if (vals.r !== undefined || vals.red !== undefined) {
this.setValues('rgb', vals);
} else if (vals.l !== undefined || vals.lightness !== undefined) {
this.setValues('hsl', vals);
} else if (vals.v !== undefined || vals.value !== undefined) {
this.setValues('hsv', vals);
} else if (vals.w !== undefined || vals.whiteness !== undefined) {
this.setValues('hwb', vals);
this.values = {
rgb: [0, 0, 0],
hsl: [0, 0, 0],
hsv: [0, 0, 0],
hwb: [0, 0, 0],
cmyk: [0, 0, 0, 0],
alpha: 1
};
// parse Color() argument
var vals;
if (typeof obj === 'string') {
vals = string.getRgba(obj);
if (vals) {
this.setValues('rgb', vals);
} else if (vals = string.getHsla(obj)) {
this.setValues('hsl', vals);
} else if (vals = string.getHwb(obj)) {
this.setValues('hwb', vals);
} else {
throw new Error('Unable to parse color from string "' + obj + '"');
}
} else if (typeof obj === 'object') {
vals = obj;
if (vals.r !== undefined || vals.red !== undefined) {
this.setValues('rgb', vals);
} else if (vals.l !== undefined || vals.lightness !== undefined) {
this.setValues('hsl', vals);
} else if (vals.v !== undefined || vals.value !== undefined) {
this.setValues('hsv', vals);
} else if (vals.w !== undefined || vals.whiteness !== undefined) {
this.setValues('hwb', vals);
this.values = {
rgb: [0, 0, 0],
hsl: [0, 0, 0],
hsv: [0, 0, 0],
hwb: [0, 0, 0],
cmyk: [0, 0, 0, 0],
alpha: 1
}
// parse Color() argument
if (typeof obj == "string") {
var vals = string.getRgba(obj);
if (vals) {
this.setValues("rgb", vals);
}
else if(vals = string.getHsla(obj)) {
this.setValues("hsl", vals);
}
else if(vals = string.getHwb(obj)) {
this.setValues("hwb", vals);
}
else {
throw new Error("Unable to parse color from string \"" + obj + "\"");
}
}
else if (typeof obj == "object") {
var vals = obj;
if(vals["r"] !== undefined || vals["red"] !== undefined) {
this.setValues("rgb", vals)
}
else if(vals["l"] !== undefined || vals["lightness"] !== undefined) {
this.setValues("hsl", vals)
this.values = {
rgb: [0, 0, 0],
hsl: [0, 0, 0],
hsv: [0, 0, 0],
hwb: [0, 0, 0],
cmyk: [0, 0, 0, 0],
alpha: 1
}
// parse Color() argument
if (typeof cssString == "string") {
var vals = string.getRgba(cssString);
if (vals) {
this.setValues("rgb", vals);
}
else if(vals = string.getHsla(cssString)) {
this.setValues("hsl", vals);
}
else if(vals = string.getHwb(cssString)) {
this.setValues("hwb", vals);
}
else {
throw new Error("Unable to parse color from string " + cssString);
}
}
else if (typeof cssString == "object") {
var vals = cssString;
if(vals["r"] !== undefined || vals["red"] !== undefined) {
this.setValues("rgb", vals)
}
else if(vals["l"] !== undefined || vals["lightness"] !== undefined) {
this.setValues("hsl", vals)