mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Turned the PaleteBlock into an IIFE
This commit is contained in:
12
js/Color.js
12
js/Color.js
@ -165,4 +165,16 @@ class Color {
|
||||
|
||||
return {h: myH * 360, s: myS * 100, v: myV * 100};
|
||||
}
|
||||
|
||||
/** Converts a CSS colour eg rgb(x,y,z) to a hex string
|
||||
*
|
||||
* @param {*} rgb
|
||||
*/
|
||||
static cssToHex(rgb) {
|
||||
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
||||
function hex(x) {
|
||||
return ("0" + parseInt(x).toString(16)).slice(-2);
|
||||
}
|
||||
return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user