Using the latest color version
This commit is contained in:
parent
7daa53a6d3
commit
91b7555da6
@ -9,7 +9,7 @@ function Cursor(rune)
|
|||||||
this.mode = "vertex";
|
this.mode = "vertex";
|
||||||
|
|
||||||
this.color = "#000000"
|
this.color = "#000000"
|
||||||
this.color_alt = "#ff0000"
|
this.color_alt = "#ffffff"
|
||||||
this.size = 4;
|
this.size = 4;
|
||||||
this.pos = {x:0,y:0};
|
this.pos = {x:0,y:0};
|
||||||
|
|
||||||
|
@ -1,17 +1,21 @@
|
|||||||
function Color(hex = '#000000')
|
function Color(hex = '#000000', rgb)
|
||||||
{
|
{
|
||||||
this.example = "#ff0000";
|
if(rgb){
|
||||||
this.hex = hex;
|
this.rgb = rgb;
|
||||||
|
this.hex = "#"+("0" + parseInt(rgb.r,10).toString(16)).slice(-2)+("0" + parseInt(rgb.g,10).toString(16)).slice(-2)+("0" + parseInt(rgb.b,10).toString(16)).slice(-2);
|
||||||
this.rgb = function()
|
|
||||||
{
|
|
||||||
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(this.hex);
|
|
||||||
return result ? {
|
|
||||||
r: parseInt(result[1], 16),
|
|
||||||
g: parseInt(result[2], 16),
|
|
||||||
b: parseInt(result[3], 16)
|
|
||||||
} : null;
|
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
this.hex = hex;
|
||||||
|
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(this.hex);
|
||||||
|
this.rgb = {r: parseInt(result[1], 16),g: parseInt(result[2], 16),b: parseInt(result[3], 16)}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.r = this.rgb.r;
|
||||||
|
this.g = this.rgb.g;
|
||||||
|
this.b = this.rgb.b;
|
||||||
|
|
||||||
|
this.average = parseInt((this.r + this.g + this.b)/3)
|
||||||
|
this.invert = {r:255-this.rgb.r, g:255-this.rgb.g, b:255-this.rgb.b};
|
||||||
|
|
||||||
this.rgba = function()
|
this.rgba = function()
|
||||||
{
|
{
|
||||||
@ -20,7 +24,7 @@ function Color(hex = '#000000')
|
|||||||
|
|
||||||
this.floats = function()
|
this.floats = function()
|
||||||
{
|
{
|
||||||
var rgb = this.rgb();
|
var rgb = this.rgb;
|
||||||
return { r:rgb.r/255, g:rgb.g/255, b:rgb.b/255 }
|
return { r:rgb.r/255, g:rgb.g/255, b:rgb.b/255 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user