* change the text to be displayed * @param {number|string|string[]} value - a string, or an array of strings * @returns {BitmapText} this object for chaining
(value = "")
| 173 | * @returns {BitmapText} this object for chaining |
| 174 | */ |
| 175 | setText(value = "") { |
| 176 | if (this._text.toString() !== value.toString()) { |
| 177 | if (!Array.isArray(value)) { |
| 178 | this._text = ("" + value).split("\n"); |
| 179 | } else { |
| 180 | this._text = value; |
| 181 | } |
| 182 | this.isDirty = true; |
| 183 | } |
| 184 | |
| 185 | if (this._text.length > 0 && this.wordWrapWidth > 0) { |
| 186 | this._text = this.metrics.wordWrap(this._text, this.wordWrapWidth); |
| 187 | } |
| 188 | |
| 189 | // measure text dimensions (cached for updateBounds) |
| 190 | this.metrics.measureText(this._text); |
| 191 | this.updateBounds(); |
| 192 | |
| 193 | return this; |
| 194 | } |
| 195 | |
| 196 | /** |
| 197 | * the number of characters to display (use -1 to show all). |
no test coverage detected