Added type

This commit is contained in:
Devine Lu Linvega 2017-11-08 16:56:52 +13:00
parent 99ae0747e5
commit f2f599dc7a
3 changed files with 35 additions and 1 deletions

View File

@ -11,6 +11,7 @@
<script type="text/javascript" src="scripts/modules/path.js"></script>
<script type="text/javascript" src="scripts/modules/magnet.js"></script>
<script type="text/javascript" src="scripts/modules/filter.js"></script>
<script type="text/javascript" src="scripts/modules/type.js"></script>
<script type="text/javascript" src="scripts/core/layer.js"></script>
<script type="text/javascript" src="scripts/layers/grid.js"></script>

View File

@ -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);
}
}

View File

@ -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()