PERGOLA LOGO

Miscellaneous

Other pergola properties and utility functions

pergola.decimalToHex(n)

Returns a hexadecimal string representation of n number.

pergola.find(callback)

This utility allows you to initialize and open the pergola.findDialog. To invoke you must use the function's call() method, passing the callback function. When working in the context of instances of classes inheriting from Class (superclass) you invoke instead the find() prototype method, with no need to use the function's call() method. The function creates the pergola.findDialog if it doesn't exist, by invoking the pergola.lazyLoad.findDialog(). Learn more in THE FIND DIALOG section of the Tutorial.

pergola.getColorpicker(color)

This utility initializes and opens the pergola.colorpicker. The color picker no longer exists in the two versions "basic" and "extended". With the current color picker the user can toggle between "narrow spectrum" (65535 visible colors) and "wide spectrum" (393216 visible colors). The function creates the pergola.colorpicker if it doesn't exist, by invoking the pergola.lazyLoad.colorpickerDialog(). You no longer specify the colorpicker type in the config.js file. This is done instead in the skin.js file; the value of the pergola.presentationAttributes.colorpicker.spectrum property ("wide" or "narrow") determines the initial display of the color picker.

pergola.height()

Get the computedStyle.height of the HTML container, or of the root document in standalone SVG. If computedStyle is not implemented the function returns window.innerWidth. pergola.resize() uses this value to redraw the interface on resize event in standalone SVG context.

pergola.hexToDecimal(n)

Converts n hex number to decimal.

pergola.message(m[, pos])

Shortcut: $M. Displays and updates the text of the pergola.notification dialog. The m string can contain the escape sequence “\n” for new lines. If pos (object defining x and y properties) is specified the dialog appears at user space coordinates pos.x, pos.y.

pergola.mousePoint(evt)

In HTML + SVG context uses the methods createSVGPoint(), matrixTransform(), getScreenCTM(), and inverse(). In standalone SVG context it uses evt.clientX and evt.clientY. Returns {x : x, y : y} mouse coordinates object in the user space.

The presentationAttributes object represents a style sheet, and its properties take expressions, of course. It is located in the skins.js file, where multiple sheets can be defined (the sheet to be used being defined in the config file). Most properties defined here can be overridden for the classes' instances. This technique allows to apply full customization without the need to hack the classes. Note that this does not prevent the use of the style or class attributes for any element created with the DOM helpers, or for any class instance for which the paint and geometrical attributes can be overridden. See also Skins library and the Skins chapter in the tutorial.

pergola.resize()

Callback for the "resize" event. Updates the geometry and redraws the interface (in standalone SVG only).

pergola.setCursor(element, cursor)

Set SVG "cursor" attribute. Workaround for defective implementations.

pergola.symbol(object)

Utility function to use symbols from the symbols library (lib/symbols.js) or defined inline. Use also for creating icons. Returns a group containing the symbol's elements. object must define the symbol property, which can get a symbol or an image. If symbol designates a symbol, it can be a reference to a symbol in the library (lib/symbols.js), or a symbol specified in the same format of the symbols library (an array of one or more objects in the format expected by the SVG DOM helper, without the appendTo property). If symbol designates an image, it gets the image's URL string, and the width and height properties must be specified.

Other optional properties of object: x; y; opacity; parent. if x and/or y string or number (user space units) are specified the group is translated to x,y. If opacity string or number is specified it is applied to the group. If parent node is not specified the group will be appended to this container.

This method is extensively used by Pergola classes and can be used for orphan symbols and icons using the method call(). Read also the Symbols chapter in the tutorial.

pergola.propsToArray(object)

Returns an array with the property names in object (avoids conflict with other built-in objects extension libraries).

pergola.toArray(object)

Returns an array with the property values in object (avoids conflict with other built-in objects extension libraries).

pergola.use(object)

Utility function to use the shapes library (located in lib/shapes.js); object defines the properties: shape reference to library shape, parent node, and optional paint attributes object. Returns the shape element. Read also the Shapes chapter in the tutorial.

pergola.width()

Get the computedStyle.width of the HTML container, or of the root document in standalone SVG. If computedStyle is not implemented the function returns window.innerWidth. pergola.resize() uses this value to redraw the interface on resize event in standalone SVG context.