From 74dcfd1487a59edd6cc712d659e47cd0bdd2997a Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Tue, 17 Jan 2017 09:59:44 -0700 Subject: [PATCH] Improved Typographer --- sources/media/graphics/grid_20.png | Bin 105 -> 0 bytes sources/scripts/core/commander.js | 3 ++- sources/scripts/modules/module.js | 2 +- sources/scripts/modules/surface.js | 2 +- sources/scripts/modules/surface.layer.js | 5 ++++- sources/scripts/modules/typographe.js | 16 +++++++++++++--- sources/scripts/modules/vector.js | 3 +-- 7 files changed, 22 insertions(+), 9 deletions(-) delete mode 100644 sources/media/graphics/grid_20.png diff --git a/sources/media/graphics/grid_20.png b/sources/media/graphics/grid_20.png deleted file mode 100644 index 0e6c281e6e153a9e8c1447a4cc9c04cf5ad5b8b8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 105 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE;=fv1aOh=qT$iILH-`geCM-Pp7k zS4pxIpI^~9<@lKliM}>PNkxNMIVU(wOmvkEco^FzvWV9E-vb%M;OXk;vd$@?2>{() B8$bX6 diff --git a/sources/scripts/core/commander.js b/sources/scripts/core/commander.js index c517738..6ad36cb 100644 --- a/sources/scripts/core/commander.js +++ b/sources/scripts/core/commander.js @@ -23,7 +23,8 @@ function Commander(element,element_input) function run() { - console.log("~ "+queue[0].trim()); + if(!queue[0]){ return; } + active(queue[0].trim()); queue.shift(); diff --git a/sources/scripts/modules/module.js b/sources/scripts/modules/module.js index 328c23d..7365ce1 100644 --- a/sources/scripts/modules/module.js +++ b/sources/scripts/modules/module.js @@ -9,7 +9,7 @@ function Module(rune) this.install = function() { - console.log(this.rune); + console.log("Installing "+ronin.modules[this.rune].constructor.name); } this.active = function(cmd) diff --git a/sources/scripts/modules/surface.js b/sources/scripts/modules/surface.js index a4b3865..e5d3334 100644 --- a/sources/scripts/modules/surface.js +++ b/sources/scripts/modules/surface.js @@ -55,7 +55,7 @@ function Surface(rune) this.add_layer = function(layer) { - console.log("Creating layer:"+layer.name); + console.log("Creating layer:"+layer.name+"("+(layer.manager ? layer.manager.constructor.name : "")+")"); this.layers[layer.name] = layer; this.active_layer = layer; diff --git a/sources/scripts/modules/surface.layer.js b/sources/scripts/modules/surface.layer.js index 904040a..e9e8180 100644 --- a/sources/scripts/modules/surface.layer.js +++ b/sources/scripts/modules/surface.layer.js @@ -53,7 +53,10 @@ function Layer(name,manager = null) if(ronin.surface.active_layer.name == this.name){ e_class += "highlight "; } if(this.manager != null){ e_class += "managed "; } - return "- "+e_name+"
"; + var e_icon = this.manager ? "~" : "-"; + + + return ""+e_icon+" "+e_name+"
"; } this.move_from = null; diff --git a/sources/scripts/modules/typographe.js b/sources/scripts/modules/typographe.js index 5cc1280..38eb4e5 100644 --- a/sources/scripts/modules/typographe.js +++ b/sources/scripts/modules/typographe.js @@ -3,7 +3,16 @@ function Typographe(rune) Module.call(this,rune); this.parameters = [Position,Color,Value]; - this.variables = {"text" : null}; + this.variables = {"text" : null, "font" : "Georgia"}; + + this.layer = null; + + this.install = function() + { + this.layer = new Layer("TextPreview",this); + this.layer.element.setAttribute("style","z-index:7000"); + ronin.surface.add_layer(this.layer); + } this.active = function(cmd) { @@ -16,7 +25,7 @@ function Typographe(rune) this.passive = function(cmd) { - var target = ronin.overlay; + var target = this.layer; target.clear(); if(cmd.variable("text")){ this.add_text(target.context(),cmd); @@ -31,8 +40,9 @@ function Typographe(rune) var position = cmd.position() ? cmd.position() : new Position(20,40); var color = cmd.color() ? cmd.color() : new Color("#000000"); var size = cmd.value() ? cmd.value().int : 20; + var font = cmd.variable("font") ? cmd.variable("font").value : "Georgia"; - ctx.font = size+"px Georgia"; + ctx.font = size+"px "+font; ctx.fillStyle = color.hex; ctx.fillText(text,position.x,position.y); } diff --git a/sources/scripts/modules/vector.js b/sources/scripts/modules/vector.js index 0fe0936..cb030f8 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("Preview",this); + this.layer = new Layer("PathPreview",this); this.layer.element.setAttribute("style","z-index:8000"); ronin.surface.add_layer(this.layer); } @@ -18,7 +18,6 @@ function Vector(rune) this.passive = function(cmd) { - console.log(cmd.variable("stroke_width")); this.layer.clear(); this.layer.context().lineCap = cmd.variable("line_cap") ? cmd.variable("line_cap").value : "round"; this.layer.context().lineWidth = cmd.variable("stroke_width") ? cmd.variable("stroke_width").value : ronin.brush.size;