Improved stencil
This commit is contained in:
parent
1273898220
commit
ded226c16f
@ -3,12 +3,12 @@ function Filter()
|
|||||||
this.name = "Unknown";
|
this.name = "Unknown";
|
||||||
this.parameters = [];
|
this.parameters = [];
|
||||||
|
|
||||||
this.render = function(p)
|
this.render = function(cmd)
|
||||||
{
|
{
|
||||||
console.log("render: Nothing here.");
|
console.log("render: Nothing here.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.preview = function(p)
|
this.preview = function(cmd)
|
||||||
{
|
{
|
||||||
console.log("render: Nothing here.");
|
console.log("render: Nothing here.");
|
||||||
}
|
}
|
||||||
|
@ -2,39 +2,40 @@ function Filter_Stencil()
|
|||||||
{
|
{
|
||||||
Filter.call(this);
|
Filter.call(this);
|
||||||
|
|
||||||
this.render = function()
|
this.render = function(cmd)
|
||||||
{
|
{
|
||||||
this.draw();
|
this.draw(this.context(),cmd.angle() ? cmd.angle().degrees : 20);
|
||||||
|
ronin.overlay.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.preview = function()
|
this.preview = function(cmd)
|
||||||
{
|
{
|
||||||
|
ronin.overlay.clear();
|
||||||
|
this.draw(ronin.overlay.context(),cmd.angle() ? cmd.angle().degrees : 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.draw = function()
|
this.draw = function(context = this.context(), angle = 20)
|
||||||
{
|
{
|
||||||
var context = this.context();
|
|
||||||
var w = ronin.surface.size.width;
|
var w = ronin.surface.size.width;
|
||||||
var h = ronin.surface.size.height;
|
var h = ronin.surface.size.height;
|
||||||
|
|
||||||
context.translate(w/2,h/2);
|
context.translate(w/2,h/2);
|
||||||
|
|
||||||
context.rotate(20*Math.PI/180);
|
context.rotate(angle*Math.PI/180);
|
||||||
|
|
||||||
this.line(-w,0,w,0);
|
this.line(context,-w,0,w,0);
|
||||||
|
|
||||||
this.line(w*0.4,-h,w*0.4,h);
|
this.line(context,w*0.4,-h,w*0.4,h);
|
||||||
this.line(-w*0.4,-h,-w*0.4,h);
|
this.line(context,-w*0.4,-h,-w*0.4,h);
|
||||||
|
|
||||||
this.line(-w,h*0.25,w,h*0.25);
|
this.line(context,-w,h*0.25,w,h*0.25);
|
||||||
this.line(-w,-h*0.25,w,-h*0.25);
|
this.line(context,-w,-h*0.25,w,-h*0.25);
|
||||||
|
|
||||||
this.line(w*0.1,0,w*0.1,h);
|
this.line(context,w*0.1,0,w*0.1,h);
|
||||||
this.line(-w*0.1,0,-w*0.1,-h);
|
this.line(context,-w*0.1,0,-w*0.1,-h);
|
||||||
|
|
||||||
this.circle(w*0.4,-h*0.25,w*0.05,1,1.5);
|
this.circle(context,w*0.4,-h*0.25,w*0.05,1,1.5);
|
||||||
this.circle(-w*0.4,h*0.25,w*0.05,0,0.5);
|
this.circle(context,-w*0.4,h*0.25,w*0.05,0,0.5);
|
||||||
|
|
||||||
context.font = "5px Arial";
|
context.font = "5px Arial";
|
||||||
context.fillStyle = "#000000";
|
context.fillStyle = "#000000";
|
||||||
@ -44,32 +45,30 @@ function Filter_Stencil()
|
|||||||
context.fillStyle = "#000000";
|
context.fillStyle = "#000000";
|
||||||
context.fillText("GRID",(-w*0.4)-20,-10);
|
context.fillText("GRID",(-w*0.4)-20,-10);
|
||||||
|
|
||||||
context.rotate(-20*Math.PI/180);
|
context.rotate(-angle*Math.PI/180);
|
||||||
context.translate(-w/2,-h/2);
|
context.translate(-w/2,-h/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.line = function(x1,x2,y1,y2)
|
this.line = function(context,x1,x2,y1,y2)
|
||||||
{
|
{
|
||||||
this.context().beginPath();
|
context.beginPath();
|
||||||
|
context.moveTo(x1,x2);
|
||||||
this.context().moveTo(x1,x2);
|
context.lineTo(y1,y2);
|
||||||
this.context().lineTo(y1,y2);
|
context.lineCap="round";
|
||||||
|
context.lineWidth = 0.5;
|
||||||
this.context().lineCap="round";
|
context.strokeStyle = "#000";
|
||||||
this.context().lineWidth = 0.5;
|
context.stroke();
|
||||||
this.context().strokeStyle = "#000";
|
context.closePath();
|
||||||
this.context().stroke();
|
|
||||||
this.context().closePath();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.circle = function(x,y,r,c1,c2)
|
this.circle = function(context,x,y,r,c1,c2)
|
||||||
{
|
{
|
||||||
this.context().beginPath();
|
context.beginPath();
|
||||||
this.context().arc(x,y,r,c1*Math.PI,c2*Math.PI);
|
context.arc(x,y,r,c1*Math.PI,c2*Math.PI);
|
||||||
this.context().lineCap="round";
|
context.lineCap="round";
|
||||||
this.context().lineWidth = 0.5;
|
context.lineWidth = 0.5;
|
||||||
this.context().strokeStyle = "#000";
|
context.strokeStyle = "#000";
|
||||||
this.context().stroke();
|
context.stroke();
|
||||||
this.context().closePath();
|
context.closePath();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,12 +15,18 @@ function Render(rune)
|
|||||||
|
|
||||||
cmd.content.shift();
|
cmd.content.shift();
|
||||||
|
|
||||||
return this.collection[name].render(cmd.content);
|
return this.collection[name].render(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.passive = function(cmd)
|
this.passive = function(cmd)
|
||||||
{
|
{
|
||||||
|
var name = cmd.content[0];
|
||||||
|
if(!this.collection[name]){ console.log("Unknown filter:"+name); return; }
|
||||||
|
|
||||||
|
cmd.content.shift();
|
||||||
|
|
||||||
|
console.log(name);
|
||||||
|
return this.collection[name].preview(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user