A.1 Color Styles
A color style has a fill color, a stroke color, or both.
When applied to a shape or geometry, the fill color (if present) is used to fill the interior of the shape, and the stroke color (if present) is used to draw the boundaries of the shape. Either color can also have an alpha value, which controls the transparency of that color.
For color styles, the class
attribute of the <g>
element must be set to "color"
. The <g>
element must have a style
attribute, which specifies the color components and their optional alpha value. For example:
-
<g class="color" style="fill:#ff0000">
specifies a color style with only a fill color (whose RGB value is #ff0000). -
<g class="color" style="fill:#ff0000;stroke:blue">
specifies a color style with a fill color and a stroke color (blue).
You can specify a color value using either a hexadecimal string (such as #00ff00) or a color name from the following list: black, blue, cyan, darkGray, gray, green, lightGray, magenta, orange, pink, red, white, yellow.
To specify transparency for a color style, you can specify fill-opacity
and stroke-opacity
values from 0 (completely transparent) to 255 (opaque). The following example specifies a fill component with half transparency:
<g class="color" style="fill:#ff00ff;fill-opacity:128">
The following example specifies both stroke and fill opacity:
<g class="color" style= "stroke:red;stroke-opacity:70; fill:#ff00aa;fill-opacity:129">
The syntax for the style
attribute is a string composed of one or more name:value
pairs delimited by semicolons. (This basic syntax is used in other types of styles as well.)
For stroke colors, you can define a stroke width. The default stroke width when drawing a shape boundary is 1 pixel. To change that, add a stroke-width:
value
pair to the style
attribute string. The following example specifies a stroke width of 3 pixels:
<g class="color" style="stroke:red;stroke-width:3">