From d768306ab10cb458187a85f06bb533d157e42fd6 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Wed, 18 Jan 2017 09:37:22 -0700 Subject: [PATCH] Fixed issue with stencil --- sources/scripts/filters/stencil.js | 46 +++++++++++++----------- sources/scripts/modules/file.save.js | 2 +- sources/scripts/modules/overlay.js | 2 +- sources/scripts/modules/render.js | 11 +++++- sources/scripts/modules/surface.layer.js | 1 - sources/scripts/modules/typographe.js | 2 +- sources/scripts/modules/vector.js | 2 +- 7 files changed, 40 insertions(+), 26 deletions(-) diff --git a/sources/scripts/filters/stencil.js b/sources/scripts/filters/stencil.js index aaaa56e..49d420c 100644 --- a/sources/scripts/filters/stencil.js +++ b/sources/scripts/filters/stencil.js @@ -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(); } diff --git a/sources/scripts/modules/file.save.js b/sources/scripts/modules/file.save.js index 3f112f5..4613718 100644 --- a/sources/scripts/modules/file.save.js +++ b/sources/scripts/modules/file.save.js @@ -11,7 +11,7 @@ function FileSave(rune) this.install = function() { - this.layer = new Layer("Export",this); + this.layer = new Layer("Save.Export",this); ronin.surface.add_layer(this.layer); } diff --git a/sources/scripts/modules/overlay.js b/sources/scripts/modules/overlay.js index 81d36c1..385258b 100644 --- a/sources/scripts/modules/overlay.js +++ b/sources/scripts/modules/overlay.js @@ -9,7 +9,7 @@ function Overlay(rune) this.install = function() { - this.layer = new Layer("Guide",this); + this.layer = new Layer("Overlay.Guide",this); this.layer.element.setAttribute("style","z-index:9000"); ronin.surface.add_layer(this.layer); } diff --git a/sources/scripts/modules/render.js b/sources/scripts/modules/render.js index 6e3ac19..a1b023c 100644 --- a/sources/scripts/modules/render.js +++ b/sources/scripts/modules/render.js @@ -9,6 +9,15 @@ function Render(rune) this.collection["rotate"] = new Filter_Rotate(); this.collection["invert"] = new Filter_Invert(); this.collection["chromatic"] = new Filter_Chromatic(); + + this.layer = null; + + this.install = function() + { + this.layer = new Layer("Render.Preview",this); + this.layer.element.setAttribute("style","z-index:9000"); + ronin.surface.add_layer(this.layer); + } this.active = function(cmd) { @@ -29,7 +38,7 @@ function Render(rune) this.hint = function(cmd) { - var input = cmd.content.join(" "); + var input = cmd.content.join(" ").trim(); var s = this.pad(input); if(this.collection[input]){ diff --git a/sources/scripts/modules/surface.layer.js b/sources/scripts/modules/surface.layer.js index e9e8180..f90f1a7 100644 --- a/sources/scripts/modules/surface.layer.js +++ b/sources/scripts/modules/surface.layer.js @@ -45,7 +45,6 @@ function Layer(name,manager = null) this.widget = function() { var e_name = ""; - if(this.manager != null){ e_name += this.manager.constructor.name+"."; } e_name += this.name; var e_class = ""; diff --git a/sources/scripts/modules/typographe.js b/sources/scripts/modules/typographe.js index 38eb4e5..cd2aaf8 100644 --- a/sources/scripts/modules/typographe.js +++ b/sources/scripts/modules/typographe.js @@ -9,7 +9,7 @@ function Typographe(rune) this.install = function() { - this.layer = new Layer("TextPreview",this); + this.layer = new Layer("Typographe.Preview",this); this.layer.element.setAttribute("style","z-index:7000"); ronin.surface.add_layer(this.layer); } diff --git a/sources/scripts/modules/vector.js b/sources/scripts/modules/vector.js index cb030f8..74edcfd 100644 --- a/sources/scripts/modules/vector.js +++ b/sources/scripts/modules/vector.js @@ -9,7 +9,7 @@ function Vector(rune) this.install = function() { - this.layer = new Layer("PathPreview",this); + this.layer = new Layer("Vector.Preview",this); this.layer.element.setAttribute("style","z-index:8000"); ronin.surface.add_layer(this.layer); }