14 January 2003

4 Basic Data Types and Interfaces


Contents


4.1 Basic data types

The common data types for SVG's properties and attributes fall into the following categories:


4.2 Recognized color keyword names

The following is the list of recognized color keywords that can be used as a keyword value for data type <color>:

aliceblue color-patch aliceblue rgb(240, 248, 255)
antiquewhite color-patch antiquewhite rgb(250, 235, 215)
aqua color-patch aqua rgb( 0, 255, 255)
aquamarine color-patch aquamarine rgb(127, 255, 212)
azure color-patch azure rgb(240, 255, 255)
beige color-patch beige rgb(245, 245, 220)
bisque color-patch bisque rgb(255, 228, 196)
black color-patch black rgb( 0, 0, 0)
blanchedalmond color-patch blanchedalmond rgb(255, 235, 205)
blue color-patch blue rgb( 0, 0, 255)
blueviolet color-patch blueviolet rgb(138, 43, 226)
brown color-patch brown rgb(165, 42, 42)
burlywood color-patch burlywood rgb(222, 184, 135)
cadetblue color-patch cadetblue rgb( 95, 158, 160)
chartreuse color-patch chartreuse rgb(127, 255, 0)
chocolate color-patch chocolate rgb(210, 105, 30)
coral color-patch coral rgb(255, 127, 80)
cornflowerblue color-patch cornflowerblue rgb(100, 149, 237)
cornsilk color-patch cornsilk rgb(255, 248, 220)
crimson color-patch crimson rgb(220, 20, 60)
cyan color-patch cyan rgb( 0, 255, 255)
darkblue color-patch darkblue rgb( 0, 0, 139)
darkcyan color-patch darkcyan rgb( 0, 139, 139)
darkgoldenrod color-patch darkgoldenrod rgb(184, 134, 11)
darkgray color-patch darkgray rgb(169, 169, 169)
darkgreen color-patch darkgreen rgb( 0, 100, 0)
darkgrey color-patch darkgrey rgb(169, 169, 169)
darkkhaki color-patch darkkhaki rgb(189, 183, 107)
darkmagenta color-patch darkmagenta rgb(139, 0, 139)
darkolivegreen color-patch darkolivegreen rgb( 85, 107, 47)
darkorange color-patch darkorange rgb(255, 140, 0)
darkorchid color-patch darkorchid rgb(153, 50, 204)
darkred color-patch darkred rgb(139, 0, 0)
darksalmon color-patch darksalmon rgb(233, 150, 122)
darkseagreen color-patch darkseagreen rgb(143, 188, 143)
darkslateblue color-patch darkslateblue rgb( 72, 61, 139)
darkslategray color-patch darkslategray rgb( 47, 79, 79)
darkslategrey color-patch darkslategrey rgb( 47, 79, 79)
darkturquoise color-patch darkturquoise rgb( 0, 206, 209)
darkviolet color-patch darkviolet rgb(148, 0, 211)
deeppink color-patch deeppink rgb(255, 20, 147)
deepskyblue color-patch deepskyblue rgb( 0, 191, 255)
dimgray color-patch dimgray rgb(105, 105, 105)
dimgrey color-patch dimgrey rgb(105, 105, 105)
dodgerblue color-patch dodgerblue rgb( 30, 144, 255)
firebrick color-patch firebrick rgb(178, 34, 34)
floralwhite color-patch floralwhite rgb(255, 250, 240)
forestgreen color-patch forestgreen rgb( 34, 139, 34)
fuchsia color-patch fuchsia rgb(255, 0, 255)
gainsboro color-patch gainsboro rgb(220, 220, 220)
ghostwhite color-patch ghostwhite rgb(248, 248, 255)
gold color-patch gold rgb(255, 215, 0)
goldenrod color-patch goldenrod rgb(218, 165, 32)
gray color-patch gray rgb(128, 128, 128)
grey color-patch grey rgb(128, 128, 128)
green color-patch green rgb( 0, 128, 0)
greenyellow color-patch greenyellow rgb(173, 255, 47)
honeydew color-patch honeydew rgb(240, 255, 240)
hotpink color-patch hotpink rgb(255, 105, 180)
indianred color-patch indianred rgb(205, 92, 92)
indigo color-patch indigo rgb( 75, 0, 130)
ivory color-patch ivory rgb(255, 255, 240)
khaki color-patch khaki rgb(240, 230, 140)
lavender color-patch lavender rgb(230, 230, 250)
lavenderblush color-patch lavenderblush rgb(255, 240, 245)
lawngreen color-patch lawngreen rgb(124, 252, 0)
lemonchiffon color-patch lemonchiffon rgb(255, 250, 205)
lightblue color-patch lightblue rgb(173, 216, 230)
lightcoral color-patch lightcoral rgb(240, 128, 128)
lightcyan color-patch lightcyan rgb(224, 255, 255)
lightgoldenrodyellow color-patch lightgoldenrodyellow rgb(250, 250, 210)
lightgray color-patch lightgray rgb(211, 211, 211)
lightgreen color-patch lightgreen rgb(144, 238, 144)
lightgrey color-patch lightgrey rgb(211, 211, 211)
    
lightpink color-patch lightpink rgb(255, 182, 193)
lightsalmon color-patch lightsalmon rgb(255, 160, 122)
lightseagreen color-patch lightseagreen rgb( 32, 178, 170)
lightskyblue color-patch lightskyblue rgb(135, 206, 250)
lightslategray color-patch lightslategray rgb(119, 136, 153)
lightslategrey color-patch lightslategrey rgb(119, 136, 153)
lightsteelblue color-patch lightsteelblue rgb(176, 196, 222)
lightyellow color-patch lightyellow rgb(255, 255, 224)
lime color-patch lime rgb( 0, 255, 0)
limegreen color-patch limegreen rgb( 50, 205, 50)
linen color-patch linen rgb(250, 240, 230)
magenta color-patch magenta rgb(255, 0, 255)
maroon color-patch maroon rgb(128, 0, 0)
mediumaquamarine color-patch mediumaquamarine rgb(102, 205, 170)
mediumblue color-patch mediumblue rgb( 0, 0, 205)
mediumorchid color-patch mediumorchid rgb(186, 85, 211)
mediumpurple color-patch mediumpurple rgb(147, 112, 219)
mediumseagreen color-patch mediumseagreen rgb( 60, 179, 113)
mediumslateblue color-patch mediumslateblue rgb(123, 104, 238)
mediumspringgreen color-patch mediumspringgreen rgb( 0, 250, 154)
mediumturquoise color-patch mediumturquoise rgb( 72, 209, 204)
mediumvioletred color-patch mediumvioletred rgb(199, 21, 133)
midnightblue color-patch midnightblue rgb( 25, 25, 112)
mintcream color-patch mintcream rgb(245, 255, 250)
mistyrose color-patch mistyrose rgb(255, 228, 225)
moccasin color-patch moccasin rgb(255, 228, 181)
navajowhite color-patch navajowhite rgb(255, 222, 173)
navy color-patch navy rgb( 0, 0, 128)
oldlace color-patch oldlace rgb(253, 245, 230)
olive color-patch olive rgb(128, 128, 0)
olivedrab color-patch olivedrab rgb(107, 142, 35)
orange color-patch orange rgb(255, 165, 0)
orangered color-patch orangered rgb(255, 69, 0)
orchid color-patch orchid rgb(218, 112, 214)
palegoldenrod color-patch palegoldenrod rgb(238, 232, 170)
palegreen color-patch palegreen rgb(152, 251, 152)
paleturquoise color-patch paleturquoise rgb(175, 238, 238)
palevioletred color-patch palevioletred rgb(219, 112, 147)
papayawhip color-patch papayawhip rgb(255, 239, 213)
peachpuff color-patch peachpuff rgb(255, 218, 185)
peru color-patch peru rgb(205, 133, 63)
pink color-patch pink rgb(255, 192, 203)
plum color-patch plum rgb(221, 160, 221)
powderblue color-patch powderblue rgb(176, 224, 230)
purple color-patch purple rgb(128, 0, 128)
red color-patch red rgb(255, 0, 0)
rosybrown color-patch rosybrown rgb(188, 143, 143)
royalblue color-patch royalblue rgb( 65, 105, 225)
saddlebrown color-patch saddlebrown rgb(139, 69, 19)
salmon color-patch salmon rgb(250, 128, 114)
sandybrown color-patch sandybrown rgb(244, 164, 96)
seagreen color-patch seagreen rgb( 46, 139, 87)
seashell color-patch seashell rgb(255, 245, 238)
sienna color-patch sienna rgb(160, 82, 45)
silver color-patch silver rgb(192, 192, 192)
skyblue color-patch skyblue rgb(135, 206, 235)
slateblue color-patch slateblue rgb(106, 90, 205)
slategray color-patch slategray rgb(112, 128, 144)
slategrey color-patch slategrey rgb(112, 128, 144)
snow color-patch snow rgb(255, 250, 250)
springgreen color-patch springgreen rgb( 0, 255, 127)
steelblue color-patch steelblue rgb( 70, 130, 180)
tan color-patch tan rgb(210, 180, 140)
teal color-patch teal rgb( 0, 128, 128)
thistle color-patch thistle rgb(216, 191, 216)
tomato color-patch tomato rgb(255, 99, 71)
turquoise color-patch turquoise rgb( 64, 224, 208)
violet color-patch violet rgb(238, 130, 238)
wheat color-patch wheat rgb(245, 222, 179)
white color-patch white rgb(255, 255, 255)
whitesmoke color-patch whitesmoke rgb(245, 245, 245)
yellow color-patch yellow rgb(255, 255, 0)
yellowgreen color-patch yellowgreen rgb(154, 205, 50)
blank entry    

4.3 Basic DOM interfaces

The following interfaces are defined below: SVGElement, SVGAnimatedBoolean, SVGAnimatedString, SVGStringList, SVGAnimatedEnumeration, SVGAnimatedInteger, SVGNumber, SVGAnimatedNumber, SVGNumberList, SVGAnimatedNumberList, SVGLength, SVGAnimatedLength, SVGLengthList, SVGAnimatedLengthList, SVGAngle, SVGAnimatedAngle, SVGColor, SVGICCColor, SVGRect, SVGAnimatedRect, SVGUnitTypes, SVGStylable, SVGLocatable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox, SVGZoomAndPan, SVGViewSpec, SVGURIReference, SVGCSSRule, SVGRenderingIntent.


Interface SVGElement

All of the SVG DOM interfaces that correspond directly to elements in the SVG language (e.g., the SVGPathElement interface corresponds directly to the 'path' element in the language) are derivative from base class SVGElement.


IDL Definition
interface SVGElement : Element { 
           attribute DOMString id;
                       // raises DOMException on setting
           attribute DOMString xmlbase;
                       // raises DOMException on setting
  readonly attribute SVGSVGElement ownerSVGElement;
  readonly attribute SVGElement viewportElement;
};

Attributes
DOMString id
The value of the id attribute on the given element.
Exceptions on setting
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised on an attempt to change the value of a readonly attribute.
DOMString xmlbase
Corresponds to attribute xml:base on the given element.
Exceptions on setting
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised on an attempt to change the value of a readonly attribute.
readonly SVGSVGElement ownerSVGElement
The nearest ancestor 'svg' element. Null if the given element is the outermost 'svg' element.
readonly SVGElement viewportElement
The element which established the current viewport. Often, the nearest ancestor 'svg' element. Null if the given element is the outermost 'svg' element.

Interface SVGAnimatedBoolean

Used for attributes of type boolean which can be animated.

IDL Definition
interface SVGAnimatedBoolean { 
           attribute boolean baseVal;
                       // raises DOMException on setting
  readonly attribute boolean animVal;
};

Attributes
boolean baseVal
The base value of the given attribute before applying any animations.
Exceptions on setting
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised on an attempt to change the value of a readonly attribute.
readonly boolean animVal
If the given attribute or property is being animated, contains the current animated value of the attribute or property. If the given attribute or property is not currently being animated, contains the same value as 'baseVal'.

Interface SVGAnimatedString

Used for attributes of type DOMString which can be animated.

IDL Definition
interface SVGAnimatedString { 
           attribute DOMString baseVal;
                       // raises DOMException on setting
  readonly attribute DOMString animVal;
};

Attributes
DOMString baseVal
The base value of the given attribute before applying any animations.
Exceptions on setting
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised on an attempt to change the value of a readonly attribute.
readonly DOMString animVal
If the given attribute or property is being animated, contains the current animated value of the attribute or property. If the given attribute or property is not currently being animated, contains the same value as 'baseVal'.

Interface SVGStringList

This interface defines a list of DOMString objects.

SVGStringList has the same attributes and methods as other SVGxxxList interfaces. Implementers may consider using a single base class to implement the various SVGxxxList interfaces.


IDL Definition
interface SVGStringList { 
  readonly attribute unsigned long numberOfItems;
  void   clear (  )
                  raises( DOMException );
  DOMString initialize ( in DOMString newItem )
                  raises( DOMException, SVGException );
  DOMString getItem ( in unsigned long index )
                  raises( DOMException );
  DOMString insertItemBefore ( in DOMString newItem, in unsigned long index )
                  raises( DOMException, SVGException );
  DOMString replaceItem ( in DOMString newItem, in unsigned long index )
                  raises( DOMException, SVGException );
  DOMString removeItem ( in unsigned long index )
                  raises( DOMException );
  DOMString appendItem ( in DOMString newItem )
                  raises( DOMException, SVGException );
};

Attributes
readonly unsigned long numberOfItems
The number of items in the list.
Methods
clear
Clears all existing current items from the list, with the result being an empty list.
No Parameters
No Return Value
Exceptions
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised when the list cannot be modified.
initialize
Clears all existing current items from the list and re-initializes the list to hold the single item specified by the parameter.
Parameters
in DOMString newItem The item which should become the only member of the list.
Return value
DOMString The item being inserted into the list.
Exceptions
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised when the list cannot be modified.
SVGException
SVG_WRONG_TYPE_ERR: Raised if parameter newItem is the wrong type of object for the given list.
getItem
Returns the specified item from the list.
Parameters
in unsigned long index The index of the item from the list which is to be returned. The first item is number 0.
Return value
DOMString The selected item.
Exceptions
DOMException
INDEX_SIZE_ERR: Raised if the index number is negative or greater than or equal to numberOfItems.
insertItemBefore
Inserts a new item into the list at the specified position. The first item is number 0. If newItem is already in a list, it is removed from its previous list before it is inserted into this list.
Parameters
in DOMString newItem The item which is to be inserted into the list.
in unsigned long index The index of the item before which the new item is to be inserted. The first item is number 0.
If the index is equal to 0, then the new item is inserted at the front of the list. If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list.
Return value
DOMString The inserted item.
Exceptions
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised when the list cannot be modified.
SVGException
SVG_WRONG_TYPE_ERR: Raised if parameter newItem is the wrong type of object for the given list.
replaceItem
Replaces an existing item in the list with a new item. If newItem is already in a list, it is removed from its previous list before it is inserted into this list.
Parameters
in DOMString newItem The item which is to be inserted into the list.
in unsigned long index The index of the item which is to be replaced. The first item is number 0.
Return value
DOMString The inserted item.
Exceptions
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised when the list cannot be modified.
INDEX_SIZE_ERR: Raised if the index number is negative or greater than or equal to numberOfItems.
SVGException
SVG_WRONG_TYPE_ERR: Raised if parameter newItem is the wrong type of object for the given list.
removeItem
Removes an existing item from the list.
Parameters
in unsigned long index The index of the item which is to be removed. The first item is number 0.
Return value
DOMString The removed item.
Exceptions
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised when the list cannot be modified.
INDEX_SIZE_ERR: Raised if the index number is negative or greater than or equal to numberOfItems.
appendItem
Inserts a new item at the end of the list. If newItem is already in a list, it is removed from its previous list before it is inserted into this list.
Parameters
in DOMString newItem The item which is to be inserted into the list. The first item is number 0.
Return value
DOMString The inserted item.
Exceptions
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised when the list cannot be modified.
SVGException
SVG_WRONG_TYPE_ERR: Raised if parameter newItem is the wrong type of object for the given list.

Interface SVGAnimatedEnumeration

Used for attributes whose value must be a constant from a particular enumeration and which can be animated.

IDL Definition
interface SVGAnimatedEnumeration { 
           attribute unsigned short baseVal;
                       // raises DOMException on setting
  readonly attribute unsigned short animVal;
};

Attributes
unsigned short baseVal
The base value of the given attribute before applying any animations.
Exceptions on setting
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised on an attempt to change the value of a readonly attribute.
readonly unsigned short animVal
If the given attribute or property is being animated, contains the current animated value of the attribute or property. If the given attribute or property is not currently being animated, contains the same value as 'baseVal'.

Interface SVGAnimatedInteger

Used for attributes of basic type 'integer' which can be animated.

IDL Definition
interface SVGAnimatedInteger { 
           attribute long baseVal;
                       // raises DOMException on setting
  readonly attribute long animVal;
};

Attributes
long baseVal
The base value of the given attribute before applying any animations.
Exceptions on setting
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised on an attempt to change the value of a readonly attribute.
readonly long animVal
If the given attribute or property is being animated, contains the current animated value of the attribute or property. If the given attribute or property is not currently being animated, contains the same value as 'baseVal'.

Interface SVGNumber

Used for attributes of basic type 'number'.

IDL Definition
interface SVGNumber { 
           attribute float value;
                       // raises DOMException on setting
};

Attributes
float value
The value of the given attribute.
Exceptions on setting
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised on an attempt to change the value of a readonly attribute.

Interface SVGAnimatedNumber

Used for attributes of basic type 'number' which can be animated.

IDL Definition
interface SVGAnimatedNumber { 
           attribute float baseVal;
                       // raises DOMException on setting
  readonly attribute float animVal;
};

Attributes
float baseVal
The base value of the given attribute before applying any animations.
Exceptions on setting
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised on an attempt to change the value of a readonly attribute.
readonly float animVal
If the given attribute or property is being animated, contains the current animated value of the attribute or property. If the given attribute or property is not currently being animated, contains the same value as 'baseVal'.

Interface SVGNumberList

This interface defines a list of SVGNumber objects.

SVGNumberList has the same attributes and methods as other SVGxxxList interfaces. Implementers may consider using a single base class to implement the various SVGxxxList interfaces.


IDL Definition
interface SVGNumberList { 
  readonly attribute unsigned long numberOfItems;
  void   clear (  )
                  raises( DOMException );
  SVGNumber initialize ( in SVGNumber newItem )
                  raises( DOMException, SVGException );
  SVGNumber getItem ( in unsigned long index )
                  raises( DOMException );
  SVGNumber insertItemBefore ( in SVGNumber newItem, in unsigned long index )
                  raises( DOMException, SVGException );
  SVGNumber replaceItem ( in SVGNumber newItem, in unsigned long index )
                  raises( DOMException, SVGException );
  SVGNumber removeItem ( in unsigned long index )
                  raises( DOMException );
  SVGNumber appendItem ( in SVGNumber newItem )
                  raises( DOMException, SVGException );
};

Attributes
readonly unsigned long numberOfItems
The number of items in the list.
Methods
clear
Clears all existing current items from the list, with the result being an empty list.
No Parameters
No Return Value
Exceptions
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised when the list cannot be modified.
initialize
Clears all existing current items from the list and re-initializes the list to hold the single item specified by the parameter.
Parameters
in SVGNumber newItem The item which should become the only member of the list.
Return value
SVGNumber The item being inserted into the list.
Exceptions
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised when the list cannot be modified.
SVGException
SVG_WRONG_TYPE_ERR: Raised if parameter newItem is the wrong type of object for the given list.
getItem
Returns the specified item from the list.
Parameters
in unsigned long index The index of the item from the list which is to be returned. The first item is number 0.
Return value
SVGNumber The selected item.
Exceptions
DOMException
INDEX_SIZE_ERR: Raised if the index number is negative or greater than or equal to numberOfItems.
insertItemBefore
Inserts a new item into the list at the specified position. The first item is number 0. If newItem is already in a list, it is removed from its previous list before it is inserted into this list.
Parameters
in SVGNumber newItem The item which is to be inserted into the list.
in unsigned long index The index of the item before which the new item is to be inserted. The first item is number 0.
If the index is equal to 0, then the new item is inserted at the front of the list. If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list.
Return value
SVGNumber The inserted item.
Exceptions
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised when the list cannot be modified.
SVGException
SVG_WRONG_TYPE_ERR: Raised if parameter newItem is the wrong type of object for the given list.
replaceItem
Replaces an existing item in the list with a new item. If newItem is already in a list, it is removed from its previous list before it is inserted into this list.
Parameters
in SVGNumber newItem The item which is to be inserted into the list.
in unsigned long index The index of the item which is to be replaced. The first item is number 0.
Return value
SVGNumber The inserted item.
Exceptions
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised when the list cannot be modified.
INDEX_SIZE_ERR: Raised if the index number is negative or greater than or equal to numberOfItems.
SVGException
SVG_WRONG_TYPE_ERR: Raised if parameter newItem is the wrong type of object for the given list.
removeItem
Removes an existing item from the list.
Parameters
in unsigned long index The index of the item which is to be removed. The first item is number 0.
Return value
SVGNumber The removed item.
Exceptions
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised when the list cannot be modified.
INDEX_SIZE_ERR: Raised if the index number is negative or greater than or equal to numberOfItems.
appendItem
Inserts a new item at the end of the list. If newItem is already in a list, it is removed from its previous list before it is inserted into this list.
Parameters
in SVGNumber newItem The item which is to be inserted into the list. The first item is number