@@ -162,11 +162,14 @@ var Text = new Class({
162162
163163 /**
164164 * Advanced wrapping algorithm that will wrap words as the line grows longer than its horizontal
165- * bounds. White space is condensed (e.g., consecutive spaces are replaced with one) . Lines are
166- * trimmed of white space before processing. Throws an error if the user was smart enough to
167- * specify a wordWrapWidth less than a single character.
165+ * bounds. Consecutive spaces will be collapsed and replaced with a single space . Lines will be
166+ * trimmed of white space before processing. Throws an error if wordWrapWidth is less than a
167+ * single character.
168168 *
169169 * @param {string } text - The text to perform word wrap detection against.
170+ * @param {CanvasRenderingContext2D } context
171+ * @param {number } wordWrapWidth
172+ * @return {string } The wrapped text.
170173 */
171174 advancedWordWrap : function ( text , context , wordWrapWidth )
172175 {
@@ -277,9 +280,12 @@ var Text = new Class({
277280
278281 /**
279282 * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal
280- * bounds.
283+ * bounds. Spaces are not collapsed and whitespace is not trimmed.
281284 *
282285 * @param {string } text - The text to perform word wrap detection against.
286+ * @param {CanvasRenderingContext2D } context
287+ * @param {number } wordWrapWidth
288+ * @return {string } The wrapped text.
283289 */
284290 basicWordWrap : function ( text , context , wordWrapWidth )
285291 {
@@ -323,6 +329,14 @@ var Text = new Class({
323329 return result ;
324330 } ,
325331
332+ /**
333+ * Runs the given text through this Text object's word wrapping and returns the results as an
334+ * array, where each element of the array corresponds to a wrapped line of text.
335+ *
336+ * @param {string } [text] - The text for which the wrapping will be calculated. If unspecified,
337+ * the Text object's current text will be used.
338+ * @return {array } An array of strings with the pieces of wrapped text.
339+ */
326340 getWrappedText : function ( text )
327341 {
328342 if ( text === undefined ) { text = this . text ; }
@@ -429,13 +443,32 @@ var Text = new Class({
429443 return this . style . setShadowFill ( enabled ) ;
430444 } ,
431445
432- // Set to null to remove
446+ /**
447+ * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by
448+ * width.
449+ *
450+ * @param {number|null } width - The maximum width of a line in pixels. Set to null to remove
451+ * wrapping.
452+ * @param {boolean } [useAdvancedWrap=false] - Whether or not to use the advanced wrapping
453+ * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false,
454+ * spaces and whitespace are left as is.
455+ * @return {this }
456+ */
433457 setWordWrapWidth : function ( width , useAdvancedWrap )
434458 {
435459 return this . style . setWordWrapWidth ( width , useAdvancedWrap ) ;
436460 } ,
437461
438- // Set to null to remove
462+ /**
463+ * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback.
464+ *
465+ * @param {function } callback - A custom function that will be responsible for wrapping the
466+ * text. It will receive two arguments: text (the string to wrap), textObject (this Text
467+ * instance). It should return the wrapped lines either as an array of lines or as a string with
468+ * newline characters in place to indicate where breaks should happen.
469+ * @param {object } [scope=null] - The scope that will be applied when the callback is invoked.
470+ * @return {this }
471+ */
439472 setWordWrapCallback : function ( callback , scope )
440473 {
441474 return this . style . setWordWrapCallback ( callback , scope ) ;
0 commit comments