_get_text : function() { var value; //if default, then create a random number to assign to the Text if (check.undefined(this._text_options.text)) { var random_integer = require('lib/util/random_integer'); value = String(random_integer()); } //if user defined, then assign it (always a String) if (check.string(this._text_options.text)) { value = this._text_options.text; } //if a Text object, then just return that if (check.instance(this._text_options.text, this._createjs.Text)) { return this._text_options.text; } //...otherwise create new Text object, initialize to value var text = new this._createjs.Text(value); //...and copy options that was set in text() to the Text object for (text_option in this._text_options) { //skipping text, as we don't want to overwrite what we initialized it to if (text_option === 'text') continue; text[text_option] = this._text_options[text_option]; } return text; },
text : function(options) { if(!(check.object(options) || check.undefined(options))) { throw new TypeError("Incorrect argument type, requires Object."); } //validated arguments: color, font, x, y, text, textAlign var validated_options; try { validated_options = argument_check(options); } catch(error) { throw error; } //text handler //if text is set, then verify it's either a createjs Text() object or something we can String() if(!check.undefined(validated_options.text)) { if (!(check.instance(validated_options.text, this._createjs.Text))) { validated_options.text = String(validated_options.text); } } //append / overwrite any options passed in for (variable in validated_options) { this._text_options[variable] = validated_options[variable]; } },