setAttributes()

Sets the SVG attributes from an attribute set.

Syntax

setAttributes(
    node om.DomNode,
    attrs om.SaxAttributes )
  1. node is the DOM node to be updated.
  2. attrs is the om.SaxAttributes object defining the attributes.

Usage

This function updates the DOM node passed as first parameter with the om.SaxAttributes object.

Note: If a SAX attribute value is NULL, the attribute is removed from the node.

The setAttributes() function should only be used to set explicitly node-level attributes. Consider using CSS style definitions with the styleList() function, or inline styling with the styleAttributeList() function.

Steps to define and use an attribute set with setAttributes():
  1. Create and fill an om.SaxAttributes object,
  2. Create the SVG DOM element with one of the fglsvgcanvas functions,
  3. Call the setAttributes() function with the node and the SAX attributes.

Example

CONSTANT COLORS_OCEAN = 1
DEFINE attr DYNAMIC ARRAY OF om.SaxAttributes,
       n om.DomNode
...
LET attr[COLORS_OCEAN] = om.SaxAttributes.create()
CALL attr[COLORS_OCEAN].addAttribute(SVGATT_FILL,           "cyan" )
CALL attr[COLORS_OCEAN].addAttribute(SVGATT_FILL_OPACITY,   "0.3" )
CALL attr[COLORS_OCEAN].addAttribute(SVGATT_STROKE,         "blue" )
...
LET n = fglsvgcanvas.polygon("10,10 10,20 20,20")
CALL fglsvgcanvas.setAttributes( n, attr[COLORS_OCEAN] )