Found a good flow for load:/draw:

This commit is contained in:
Devine Lu Linvega
2017-11-07 11:22:08 +13:00
parent 86bacd5688
commit 1c261cf166
11 changed files with 113 additions and 23 deletions

View File

@@ -59,6 +59,9 @@ function Cursor(rune)
if(ronin.commander.active_module()){
}
else if(e.shiftKey && e.altKey){
ronin.brush.pick(ronin.cursor.line);
}
else if(e.altKey){
ronin.brush.erase(ronin.cursor.line);

View File

@@ -43,7 +43,7 @@ function Keyboard()
if(e.key == "o" && (e.ctrlKey || e.metaKey)){
e.preventDefault();
ronin.io.load();
ronin.io.methods.import();
}
if(e.key == "s" && (e.ctrlKey || e.metaKey)){

View File

@@ -33,9 +33,9 @@ function Layer()
return this.context().getImageData(x, y, width * 2, height * 2);
}
this.to_base64 = function()
this.to_base64 = function(format = 'png', quality = 0.9)
{
return this.el.toDataURL('image/png');
return format == 'png' ? this.el.toDataURL('image/png') : this.el.toDataURL('image/jpeg',0.9);
}
this.to_img = function()
@@ -49,4 +49,20 @@ function Layer()
{
this.context().clearRect(0, 0, this.el.width * 2, this.el.height * 2);
}
this.fill = function(color = "red")
{
var ctx = this.context();
ctx.beginPath();
ctx.globalCompositeOperation="source-over";
ctx.moveTo(0,0);
ctx.lineTo(this.el.width,0);
ctx.lineTo(this.el.width,this.el.height);
ctx.lineTo(0,this.el.height);
ctx.lineTo(0,0);
ctx.fillStyle = color;
ctx.fill();
ctx.closePath();
}
}

View File

@@ -11,6 +11,11 @@ function Module(name,docs = "Missing documentation.")
{
var html = "";
for(id in this.methods){
var v = this.methods[id];
html += id+": ";
}
for(setting_id in this.settings){
var setting_value = this.settings[setting_id];
html += setting_id+"="+setting_value+" ";