Migrated the rest of the units.
This commit is contained in:
@@ -14,7 +14,12 @@ function Canvas(element)
|
||||
|
||||
if(p.length > 1 && p[1].indexOf("#") >= 0){
|
||||
var color = new Color(p[1]);
|
||||
console.log("TODO: Fill with color");
|
||||
console.log(color);
|
||||
|
||||
this.element.getContext('2d').beginPath();
|
||||
this.element.getContext('2d').rect(0, 0, canvas.width, canvas.height);
|
||||
this.element.getContext('2d').fillStyle = color.hex;
|
||||
this.element.getContext('2d').fill();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
function Color(val = '000000')
|
||||
function Color(hex = '#000000')
|
||||
{
|
||||
this.val = val;
|
||||
this.hex = hex;
|
||||
|
||||
this.rgb = function()
|
||||
{
|
||||
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(this.val);
|
||||
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),
|
||||
Reference in New Issue
Block a user