Implemented brush size.

This commit is contained in:
Devine Lu Linvega 2016-11-14 14:58:08 -08:00
parent 3b067f8855
commit 1414fe0651
3 changed files with 15 additions and 5 deletions

View File

@ -19,11 +19,13 @@ function Brush()
if(cmd.color()){ if(cmd.color()){
this.color = cmd.color(); this.color = cmd.color();
} }
if(cmd.value()){
this.size = cmd.value();
}
} }
this.passive = function(cmd) this.passive = function(cmd)
{ {
console.log("Nothing to do.");
} }
// Commander // Commander

View File

@ -1,7 +1,6 @@
function Pointer(offset = new Position(), color = new Color('000000')) function Pointer(offset = new Position(), color = new Color('000000'))
{ {
this.offset = offset; this.offset = offset;
this.color = color;
this.mirror = null; this.mirror = null;
this.position_prev = null; this.position_prev = null;
@ -23,9 +22,9 @@ function Pointer(offset = new Position(), color = new Color('000000'))
this.thickness = function() this.thickness = function()
{ {
var v = 100 - ((this.position().distance_to(this.position_prev))); var ratio = 10/this.position().distance_to(this.position_prev);
var t = v/40; ratio = ratio > 1 ? 1 : ratio;
return t < 1 ? 1 : t; return ronin.brush.size * ratio;
} }
this.position = function() this.position = function()

View File

@ -33,4 +33,13 @@ function Command(cmd_array)
} }
return null; return null;
} }
this.value = function()
{
for (i = 0; i < this.cmd_array.length; i++) {
var test = /[^$\-\d]/.test(this.cmd_array[i]);
if(!test){ return parseFloat(this.cmd_array[i]); }
}
return null;
}
} }