diff --git a/sources/index.html b/sources/index.html index 8ffc81a..5f42bc7 100644 --- a/sources/index.html +++ b/sources/index.html @@ -11,6 +11,7 @@ + diff --git a/sources/scripts/modules/type.js b/sources/scripts/modules/type.js new file mode 100644 index 0000000..52b4ab2 --- /dev/null +++ b/sources/scripts/modules/type.js @@ -0,0 +1,31 @@ +function Type() +{ + Module.call(this,"type"); + + this.settings = {color:"#000000",font:"Arial"} + + this.methods.write = new Method("write","text&x,y|WxH","Draw text",function(q){ + + ronin.preview.clear(); + + var rect = q[1]; + var size = rect.height * 2 + ronin.preview.clear(); + + ronin.render.context().font = size+"px "+ronin.type.settings.font; + ronin.render.context().fillText(q[0],rect.x * 2,(rect.y * 2)+size); + }) + + this.preview = function(q) + { + if(!q.methods.write || !q.methods.write[1]){ return; } + + var rect = q.methods.write[1]; + var size = rect.height * 2 + + ronin.preview.clear(); + + ronin.preview.context().font = size+"px "+this.settings.font; + ronin.preview.context().fillText(q.methods.write[0],rect.x * 2,(rect.y * 2)+size); + } +} \ No newline at end of file diff --git a/sources/scripts/ronin.js b/sources/scripts/ronin.js index 5a6a2b4..e567480 100644 --- a/sources/scripts/ronin.js +++ b/sources/scripts/ronin.js @@ -21,6 +21,7 @@ function Ronin() this.path = new Path(); this.magnet = new Magnet(); this.filter = new Filter(); + this.type = new Type(); this.layers = { grid : this.grid, @@ -37,7 +38,8 @@ function Ronin() io : this.io, path : this.path, magnet : this.magnet, - filter : this.filter + filter : this.filter, + type : this.type }; this.install = function()