diff --git a/index.html b/index.html index cc9d60b..500b3ee 100644 --- a/index.html +++ b/index.html @@ -26,6 +26,7 @@ + diff --git a/scripts/core/commander.hint.js b/scripts/core/commander.hint.js index b82273a..cb69fda 100644 --- a/scripts/core/commander.hint.js +++ b/scripts/core/commander.hint.js @@ -52,7 +52,7 @@ function Hint(element) var s = "Modules"; for (var key in ronin.modules){ - s += ""+ronin.modules[key].constructor.name.substr(0,2)+" "+key+" "; + s += " "+key+" "+ronin.modules[key].constructor.name.substr(0,2)+" "; } return s; diff --git a/scripts/core/ronin.js b/scripts/core/ronin.js index 4314336..191dd48 100644 --- a/scripts/core/ronin.js +++ b/scripts/core/ronin.js @@ -16,6 +16,7 @@ function Ronin() this.eraser = new Eraser("."); this.surface = new Surface("#"); this.eye = new Eye("*"); + this.typo = new Typographe("&"); this.cursor = new Cursor(); @@ -31,6 +32,7 @@ function Ronin() this.modules[this.eraser.rune] = this.eraser; this.modules[this.surface.rune] = this.surface; this.modules[this.eye.rune] = this.eye; + this.modules[this.typo.rune] = this.typo; this.cursors = []; @@ -47,7 +49,6 @@ function Ronin() this.position_in_window = function(p) { - console.log(p.x); return new Position(p.x + parseInt(this.surface.element.style.marginLeft),p.y + parseInt(this.surface.element.style.marginTop)); } diff --git a/scripts/modules/typographe.js b/scripts/modules/typographe.js new file mode 100644 index 0000000..4f0b0f8 --- /dev/null +++ b/scripts/modules/typographe.js @@ -0,0 +1,39 @@ +function Typographe(rune) +{ + Module.call(this,rune); + + this.parameters = [Position,Color]; + this.variables = {"text" : null}; + + this.active = function(cmd) + { + var target = ronin.surface.active_layer; + target.clear(); + if(cmd.variable("text")){ + this.add_text(target.context(),cmd); + } + } + + this.passive = function(cmd) + { + var target = ronin.overlay; + target.clear(); + if(cmd.variable("text")){ + this.add_text(target.context(),cmd); + } + } + + this.add_text = function(context,cmd) + { + var ctx = context; + + var text = cmd.variable("text").value; + var position = cmd.position() ? cmd.position() : new Position(10,10); + var color = cmd.color() ? cmd.color() : new Color("#000000"); + var size = cmd.value() ? cmd.value().int : 20; + + ctx.font = size+"px Georgia"; + ctx.fillStyle = color.hex; + ctx.fillText(text,position.x,position.y); + } +} \ No newline at end of file