Files
prosperon/text2d.cm
2026-01-19 18:57:25 -06:00

51 lines
915 B
Plaintext

// 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)
}
}
// Factory function - auto-registers with film2d
return function(props) {
var defaults = {
type: 'text',
text: "",
pos: {x: 0, y: 0},
plane: 'default',
layer: 0,
groups: [],
font: "fonts/dos",
size: 16,
color: {r: 1, g: 1, b: 1, a: 1},
opacity: 1,
tint: {r: 1, g: 1, b: 1, a: 1},
mode: null,
sdf: null,
outline_width: null,
outline_color: null
}
var data = object(defaults, props)
var newtext = meme(text2d_proto, data)
film2d.register(newtext)
return newtext
}