Improved brush

This commit is contained in:
Devine Lu Linvega 2018-01-28 10:54:18 +13:00
parent 82b891cce2
commit 43b7746845
3 changed files with 6 additions and 8 deletions

View File

@ -83,6 +83,7 @@ function Cursor(rune)
ronin.cursor.mode = "vertex"; ronin.cursor.mode = "vertex";
ronin.cursor.query = ronin.commander.input_el.value; ronin.cursor.query = ronin.commander.input_el.value;
ronin.brush.absolute_thickness = 0;
} }
this.mouse_alt = function(e) this.mouse_alt = function(e)

View File

@ -38,7 +38,7 @@ function Brush()
var ratio = clamp(1 - (ronin.brush.speed/20),0,1) var ratio = clamp(1 - (ronin.brush.speed/20),0,1)
var t = ronin.cursor.size * ratio; var t = ronin.cursor.size * ratio;
this.absolute_thickness = t > this.absolute_thickness ? this.absolute_thickness+0.25 : this.absolute_thickness-0.25; this.absolute_thickness = t > this.absolute_thickness ? this.absolute_thickness+0.25 : this.absolute_thickness-0.25;
return this.absolute_thickness * 3; return this.absolute_thickness;
} }
this.stroke = function(line) this.stroke = function(line)
@ -88,11 +88,6 @@ function Pointer(options)
{ {
this.options = options; this.options = options;
this.thickness = function(line)
{
return ronin.brush.thickness(line);
}
this.stroke = function(line,erase = false) this.stroke = function(line,erase = false)
{ {
var ctx = ronin.cursor.target.context(); var ctx = ronin.cursor.target.context();
@ -111,7 +106,7 @@ function Pointer(options)
ctx.moveTo((line.from.x * 2) + this.options.offset.x,(line.from.y * 2) + this.options.offset.y); ctx.moveTo((line.from.x * 2) + this.options.offset.x,(line.from.y * 2) + this.options.offset.y);
ctx.lineTo((line.to.x * 2) + this.options.offset.x,(line.to.y * 2) + this.options.offset.y); ctx.lineTo((line.to.x * 2) + this.options.offset.x,(line.to.y * 2) + this.options.offset.y);
ctx.lineCap="round"; ctx.lineCap="round";
ctx.lineWidth = this.thickness(line); ctx.lineWidth = ronin.brush.thickness(line);
ctx.strokeStyle = ronin.brush.swatch.color(); ctx.strokeStyle = ronin.brush.swatch.color();
ctx.stroke(); ctx.stroke();
ctx.closePath(); ctx.closePath();

View File

@ -118,10 +118,12 @@ window.addEventListener('drop', function(e)
var files = e.dataTransfer.files; var files = e.dataTransfer.files;
var file = files[0]; var file = files[0];
var path = file.path ? file.path : file.name;
if(path.substr(-4,4) == ".thm"){ return; }
if (file.type && !file.type.match(/image.*/)) { console.log("Not image", file.type); return false; } if (file.type && !file.type.match(/image.*/)) { console.log("Not image", file.type); return false; }
var path = file.path ? file.path : file.name;
var reader = new FileReader(); var reader = new FileReader();
reader.onload = function(event) reader.onload = function(event)