rework
This commit is contained in:
57
text2d.cm
57
text2d.cm
@@ -1,14 +1,51 @@
|
||||
var text2d = {
|
||||
text: "",
|
||||
pos: {x:0,y:0},
|
||||
layer: 0,
|
||||
font: "fonts/dos",
|
||||
size: 16,
|
||||
color: {r:1,g:1,b:1,a:1}
|
||||
// text2d.cm - Text factory
|
||||
//
|
||||
// Creates text data objects that register with film2d
|
||||
|
||||
var film2d = use('film2d')
|
||||
|
||||
var text2d_proto = {
|
||||
type: 'text',
|
||||
|
||||
set_text: function(t) {
|
||||
this.text = t
|
||||
return this
|
||||
},
|
||||
|
||||
set_pos: function(x, y) {
|
||||
this.pos.x = x
|
||||
this.pos.y = y
|
||||
return this
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
film2d.unregister(this._id)
|
||||
}
|
||||
}
|
||||
|
||||
stone(text2d)
|
||||
|
||||
// Factory function - auto-registers with film2d
|
||||
return function(props) {
|
||||
return meme(text2d, props)
|
||||
var defaults = {
|
||||
type: 'text',
|
||||
text: "",
|
||||
pos: {x: 0, y: 0},
|
||||
plane: 'default',
|
||||
layer: 0,
|
||||
font: "fonts/dos",
|
||||
size: 16,
|
||||
color: {r: 1, g: 1, b: 1, a: 1},
|
||||
mode: null,
|
||||
sdf: null,
|
||||
outline_width: null,
|
||||
outline_color: null,
|
||||
tags: []
|
||||
}
|
||||
|
||||
var data = {}
|
||||
for(var k in defaults) data[k] = defaults[k]
|
||||
for(var k in props) data[k] = props[k]
|
||||
|
||||
var newtext = meme(text2d_proto, data)
|
||||
film2d.register(newtext)
|
||||
return newtext
|
||||
}
|
||||
Reference in New Issue
Block a user