Fixed issue with stencil

This commit is contained in:
Devine Lu Linvega
2017-01-18 09:37:22 -07:00
parent 74dcfd1487
commit d768306ab1
7 changed files with 40 additions and 26 deletions

View File

@@ -5,17 +5,23 @@ function Filter_Stencil()
this.render = function(cmd)
{
this.draw(this.context(),cmd.angle() ? cmd.angle().degrees : 20);
ronin.overlay.clear();
var angle = cmd.angle() ? cmd.angle().degrees : 20;
var color = cmd.color() ? cmd.color().hex : "#ffffff";
ronin.render.layer.clear();
this.draw(ronin.surface.active_layer.context(),angle,color);
}
this.preview = function(cmd)
{
ronin.overlay.clear();
this.draw(ronin.overlay.context(),cmd.angle() ? cmd.angle().degrees : 20);
var angle = cmd.angle() ? cmd.angle().degrees : 20;
var color = cmd.color() ? cmd.color().hex : "#ffffff";
ronin.render.layer.clear();
this.draw(ronin.render.layer.context(),angle,color);
}
this.draw = function(context = this.context(), angle = 20)
this.draw = function(context = this.context(), angle, color)
{
var w = ronin.surface.size.width;
var h = ronin.surface.size.height;
@@ -24,51 +30,51 @@ function Filter_Stencil()
context.rotate(angle*Math.PI/180);
this.line(context,-w,0,w,0);
this.line(context,-w,0,w,0,color);
this.line(context,w*0.4,-h,w*0.4,h);
this.line(context,-w*0.4,-h,-w*0.4,h);
this.line(context,w*0.4,-h,w*0.4,h,color);
this.line(context,-w*0.4,-h,-w*0.4,h,color);
this.line(context,-w,h*0.25,w,h*0.25);
this.line(context,-w,-h*0.25,w,-h*0.25);
this.line(context,-w,h*0.25,w,h*0.25,color);
this.line(context,-w,-h*0.25,w,-h*0.25,color);
this.line(context,w*0.1,0,w*0.1,h);
this.line(context,-w*0.1,0,-w*0.1,-h);
this.line(context,w*0.1,0,w*0.1,h,color);
this.line(context,-w*0.1,0,-w*0.1,-h,color);
this.circle(context,w*0.4,-h*0.25,w*0.05,1,1.5);
this.circle(context,-w*0.4,h*0.25,w*0.05,0,0.5);
this.circle(context,w*0.4,-h*0.25,w*0.05,1,1.5,color);
this.circle(context,-w*0.4,h*0.25,w*0.05,0,0.5,color);
context.font = "5px Arial";
context.fillStyle = "#999";
context.fillStyle = color;
context.fillText("GRID",(w*0.4)+10,10);
context.font = "5px Arial";
context.fillStyle = "#999";
context.fillStyle = color;
context.fillText("GRID",(-w*0.4)-20,-10);
context.rotate(-angle*Math.PI/180);
context.translate(-w/2,-h/2);
}
this.line = function(context,x1,x2,y1,y2)
this.line = function(context,x1,x2,y1,y2,color)
{
context.beginPath();
context.moveTo(x1,x2);
context.lineTo(y1,y2);
context.lineCap="round";
context.lineWidth = 0.5;
context.strokeStyle = "#999";
context.strokeStyle = color;
context.stroke();
context.closePath();
}
this.circle = function(context,x,y,r,c1,c2)
this.circle = function(context,x,y,r,c1,c2,color)
{
context.beginPath();
context.arc(x,y,r,c1*Math.PI,c2*Math.PI);
context.lineCap="round";
context.lineWidth = 0.5;
context.strokeStyle = "#999";
context.strokeStyle = color;
context.stroke();
context.closePath();
}