Minor updates to brush

This commit is contained in:
Devine Lu Linvega
2017-11-21 19:46:27 +13:00
parent 63715078d9
commit 4820e2b2b5
2 changed files with 13 additions and 5 deletions

View File

@@ -33,7 +33,7 @@ function Brush()
this.thickness = function(line)
{
var t = ronin.cursor.size * this.ports.speed;
this.absolute_thickness = t > this.absolute_thickness ? this.absolute_thickness+0.5 : this.absolute_thickness-0.5;
this.absolute_thickness = t > this.absolute_thickness ? this.absolute_thickness+0.25 : this.absolute_thickness-0.25;
return this.absolute_thickness * 3;
}
@@ -43,8 +43,6 @@ function Brush()
this.ports.speed = 1-distance_between(line.from,line.to)/15.0;
this.ports.distance += this.ports.speed;
// this.ports.noise = Math.random(255/255.0);
// this.ports.x = line.from.x/2;
for(pointer_id in this.pointers){
this.pointers[pointer_id].stroke(line);
@@ -82,7 +80,7 @@ function Brush()
function distance_between(a,b)
{
return Math.sqrt( (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) );
return a && b ? Math.sqrt( (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) ) : 0;
}
}
@@ -109,6 +107,10 @@ function Pointer(options)
line.to.x = (this.options.mirror.x*2) - line.to.x;
}
if(!line.to){
line.to = line.from
}
ctx.beginPath();
ctx.globalCompositeOperation="source-over";
ctx.moveTo((line.from.x * 2) + this.options.offset.x,(line.from.y * 2) + this.options.offset.y);