I'm about to publish a new CAAT actor type: Label.
This actor allows for free flowing text, either constrained to a fixed width or not, as well as definition for styles.
I'm working on adding anchoring capabilities right now.
var label= new CAAT.UI.Label().
setBounds( 100,10,500,300).
setStyle( "default", {
fontSize : 32,
fill : '#00b',
tabSize : 100
}).
setStyle( "hyper", {
filled : false,
stroked : true,
fontSize: 64,
bold : true,
italic : true,
strokeSize : 2,
fill : '#0f0'
}).
setStyle( "hyper_", {
filled : false,
stroked : true,
fontSize: 64,
strokeSize :.5,
stroke : '#0ff',
alignment : "center"
}).
setStyle( "hyper2", {
fontSize: 32,
italic : false,
strokeSize :1.5,
stroke : '#00b'
}).
setStyle( "right", {
alignment: "right"
}).
setText("<style=right>abcd<tab>def<tab>ghi</style><br>" +
"<style=hyper_>ibon</style><br><br><br>" +
"<b>bold<i>italic+bold</i></b><br>"+
"12345<fontsize=12>6789 <style=hyper>H<style=hyper2>y</style>p<style=hyper2>e</style>r",
400
).
setVerticalAlignment( CAAT.UI.ALIGNMENT.CENTER).
setHorizontalAlignment( CAAT.UI.ALIGNMENT.CENTER );
The bounds setting is optional. The label will set its vertical/horizontal alignment to the set bounds.
The second parameter in method setText is optional. If you don't set it, CAAT will calculate automatically text's bounds based on free text flow. If set, the maximum text width will be 400 units and the text will flow differently.
Currently supported styles are:
this.defaultFS = 24;
this.font = "Arial";
this.fontSize = this.defaultFS;
this.fill = '#000';
this.stroke = '#f00';
this.filled = true;
this.stroked = false;
this.strokeSize = 1;
this.italic = false;
this.bold = false;
this.alignment = "left";
this.tabSize = 75;
which can be overriden by calling setStyle( "default", { place_your_overriden_styles_here } );
Styles can be nested and will be mixed appropriately.
Let me know if you need some extra text control.
Regards,
- i