PERGOLA LOGO

String

String prototype extension properties and methods.

prototype

xmlNameStartChar

Regular expression containing illegal XML name start characters.

xmlNameChar

Regular expression containing illegal XML name characters.

toXML()

Returns this XML name conformant; illegal characters are replaced with "_".

xmlNameGenerator()

Returns this + a unique XML string composed of "XML_" + 32-bit hex number; this would typically be the empty string "", example:

 var myName = "".xmlNameGenerator();

If pergola.xmlName.exist(generated name), a new name is generated and tested.

unformatNumber(decimal)

decimal represents the locale decimal separator (radix). Returns a float representing this locale formatted number. Example:

See also pergola.radixChar.

width([fS, fF, fW, lS, k])

If fS string is specified it overrides pergola.Class.prototype["font-size"]; If fS string is specified it overrides pergola.Class.prototype["font-family"]; if fW font width string is not specified the value "normal" is used; if lS letter-spacing number or string is not specified the value "normal" is used; if k kerning number or string is not specified the value "auto" is used. Returns the BBox width of a (volatile) <text> element with this text node.

height([fS, fF])

If fS string is specified it overrides pergola.Class.prototype["font-size"]; If fS string is specified it overrides pergola.Class.prototype["font-family"]. Returns the BBox height of a (volatile) <text> element with this text node.

Note: currently the value returned by this method is not dependable because some implementations return the height of the highest glyph in the string, and some others return a value equivalent to the line height.

truncate(n)

Returns this truncated of n number of characters, starting from the end.

truncateWithDots(width[, fS, fF, fW, lS, k])

If fS string is specified it overrides pergola.Class.prototype["font-size"]; If fS string is specified it overrides pergola.Class.prototype["font-family"]; if fW font width string is not specified the value "normal" is used; if lS letter-spacing number or string is not specified the value "normal" is used; if k kerning number or string is not specified the value "auto" is used. Returns this truncated to fit the specified width, + "...".

centerVertical(height[, fS, fF])

Returns a number suitable as y value for <text> elements. Note: this method relies on the value returned by this height() and therefore is not dependable.

brighten(f)

Returns this (color string in any legal format) brightened by the specified f factor.

darken(f)

Returns this (color string in any legal format) darkened by the specified f factor.