Improved ports flow
This commit is contained in:
@@ -12,11 +12,11 @@ function Brush()
|
||||
|
||||
this.ports = {};
|
||||
|
||||
this.ports.speed = new Port("speed",false,true,0,50,"The cursor speed");
|
||||
this.ports.distance = new Port("distance",false,true,0,9999,"The cursor distance");
|
||||
this.ports.red = new Port("red",true,true,0,255,"The brush color value(red)");
|
||||
this.ports.green = new Port("green",true,true,0,255,"The brush color value(green)");
|
||||
this.ports.blue = new Port("blue",true,true,0,255,"The brush color value(blue)");
|
||||
this.ports.speed = new Port(this,"speed",false,true,0,50,"The cursor speed");
|
||||
this.ports.distance = new Port(this,"distance",false,true,0,9999,"The cursor distance");
|
||||
this.ports.red = new Port(this,"red",true,true,0,255,"The brush color value(red)");
|
||||
this.ports.green = new Port(this,"green",true,true,0,255,"The brush color value(green)");
|
||||
this.ports.blue = new Port(this,"blue",true,true,0,255,"The brush color value(blue)");
|
||||
|
||||
this.thickness = function(line)
|
||||
{
|
||||
|
||||
@@ -2,29 +2,28 @@ function Line()
|
||||
{
|
||||
Module.call(this,"line");
|
||||
|
||||
this.settings = {steps:100};
|
||||
|
||||
this.methods = {};
|
||||
|
||||
this.ports = {};
|
||||
this.ports.step = new Port(this,"step",false,true,0,100,"The tween line index.");
|
||||
this.ports.thickness = new Port(this,"thickness",true,true,4,100,"The tween line thickness.");
|
||||
|
||||
this.methods.tween = function(q)
|
||||
this.methods.tween = function(q) // line tween:$&$>>$&$ step->thickness
|
||||
{
|
||||
var from = q.from;
|
||||
var to = q.to;
|
||||
|
||||
var s = 0;
|
||||
while(s < ronin.line.settings.steps){
|
||||
var progress = s/parseFloat(ronin.line.settings.steps);
|
||||
ronin.line.ports.step.value = 0;
|
||||
while(ronin.line.ports.step.value < ronin.line.ports.step.max){
|
||||
var progress = ronin.line.ports.step.value/parseFloat(ronin.line.ports.step.max);
|
||||
var new_positions = tween_positions(from,to,progress);
|
||||
ronin.line.stroke_multi(new_positions);
|
||||
s += 1;
|
||||
ronin.line.ports.step.write(ronin.line.ports.step.value+1);
|
||||
}
|
||||
}
|
||||
|
||||
this.methods.stroke = function(q)
|
||||
{
|
||||
console.log(q)
|
||||
ronin.line.stroke_multi(q)
|
||||
}
|
||||
|
||||
@@ -47,11 +46,16 @@ function Line()
|
||||
ctx.moveTo((from.x * 2),(from.y * 2));
|
||||
ctx.lineTo((to.x * 2),(to.y * 2));
|
||||
ctx.lineCap="round";
|
||||
ctx.lineWidth = 4;
|
||||
ctx.lineWidth = clamp(ronin.line.ports.thickness.value,1,200) * 0.1;
|
||||
ctx.strokeStyle = "#000";
|
||||
ctx.stroke();
|
||||
ctx.closePath();
|
||||
}
|
||||
|
||||
function clamp(v, min, max)
|
||||
{
|
||||
return v < min ? min : v > max ? max : v;
|
||||
}
|
||||
|
||||
function tween_positions(froms,tos,progress)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user