3 Basic Data Types and Interfaces


Contents


3.1 Basic data types

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


3.2 Basic DOM interfaces


3.2.1 Overview

The section describes the basic DOM interfaces for SVG's Document Object Model that are common to multiple parts of the SVG DOM. Many of these interfaces correspond directly with SVG's basic data types.

3.2.2 Interface SVGAngle

This interface corresponds to the <angle> basic data type.

interface SVGAngle  {
  // Unit Types
  const unsigned short kSVG_ANGLETYPE_UNKNOWN     = 0;  // invalid, must be retrieved as a string
  const unsigned short kSVG_ANGLETYPE_UNSPECIFIED = 1 ; // no value provided, default kicks in
  const unsigned short kSVG_ANGLETYPE_DEG         = 2; // Degrees or unitless (means degrees)
  const unsigned short kSVG_ANGLETYPE_RAD         = 3;
  const unsigned short kSVG_ANGLETYPE_GRAD        = 4;
  readonly attribute  unsigned short unittype;

  // Setting any of these causes the other values to
  // be updated automatically.
  // If kSVG_ANGLETYPE_UNSPECIFIED, these reflect the default value.
  attribute float angle;   // in degrees
  attribute float angleInSpecifiedUnits;
  attribute DOMString angleAsString;

  // Utility methods
  void newAngleSpecifiedUnits(in unsigned short unittype, in float angleInSpecifiedUnits);
  void convertToSpecifiedUnits(in unsigned short unittype);

  // If this attribute or style property currently is being animated,
  // animatedValue reflects the current animated value of the 
  // attribute or style property.
  // Otherwise, when not animated, it will equal 'value'
  readonly attribute float animatedValue;  // in user units
};

3.2.3 Interface SVGInteger

This interface corresponds to the <integer> basic data type.

interface SVGInteger  {
  attribute long value;

  // If this attribute or style property currently is being animated,
  // animatedValue reflects the current animated value of the 
  // attribute or style property.
  // Otherwise, when not animated, it will equal 'value'
  readonly attribute float animatedValue;
};

3.2.4 Interface SVGLength

This interface corresponds to the <length> basic data type.

interface SVGLength  {
  // Unit Types
  const unsigned short kSVG_LENGTHTYPE_UNKNOWN     = 0; // invalid, must be retrieved as a string
  const unsigned short kSVG_LENGTHTYPE_UNSPECIFIED = 1; // no value provided, defaults kick in
  const unsigned short kSVG_LENGTHTYPE_NUMBER      = 2; // Unitless, meaning user units
  const unsigned short kSVG_LENGTHTYPE_PERCENTAGE  = 3;
  const unsigned short kSVG_LENGTHTYPE_EMS         = 4;
  const unsigned short kSVG_LENGTHTYPE_EXS         = 5;
  const unsigned short kSVG_LENGTHTYPE_PX          = 6;
  const unsigned short kSVG_LENGTHTYPE_CM          = 7;
  const unsigned short kSVG_LENGTHTYPE_MM          = 8;
  const unsigned short kSVG_LENGTHTYPE_IN          = 9;
  const unsigned short kSVG_LENGTHTYPE_PT          = 10;
  const unsigned short kSVG_LENGTHTYPE_PC          = 11;
  readonly attribute  unsigned short unittype;

  // Setting any of these causes the other values to
  // be updated automatically.
  // If kSVG_LENGTHTYPE_UNSPECIFIED, these reflect the default value.
  attribute float value;  // in user units
  attribute float valueInSpecifiedUnits;
  attribute DOMString valueAsString;

  // Utility methods
  void newValueSpecifiedUnits(in unsigned short unittype, in float valueInSpecifiedUnits);
  void convertToSpecifiedUnits(in unsigned short unittype);

  // If this attribute or style property currently is being animated,
  // animatedValue reflects the current animated value of the 
  // attribute or style property.
  // Otherwise, when not animated, it will equal 'value'
  readonly attribute float animatedValue;  // in user units
};

3.2.5 Interface SVGLengthList

This interface corresponds to values which represent a list of <length> values.

interface SVGLengthList  {
  SVGLength     createSVGLength();     // Returns unattached length of 0 user units

  readonly attribute  unsigned long number_of_lengths;
  SVGLength      getSVGLength(in unsigned long index);

  // Replace all existing entries with a single entry.
  void           initialize(in SVGLength newSVGLength)
                                           raises(DOMException);
  void           clear(); // Clear all entries, giving an empty list
  SVGLength      insertBefore(in SVGLength newSVGLength,
                                           in unsigned long index)
                                           raises(DOMException);
  SVGLength      replace(in SVGLength newSVGLength,
                                      in unsigned long index)
                                      raises(DOMException);
  SVGLength      remove(in unsigned long index)
                                     raises(DOMException);
  SVGLength      append(in SVGLength newSVGLength)
                                     raises(DOMException);
};

Used to values that can be expressed as an array of SVGLengths.


3.2.6 Interface SVGNumber

This interface corresponds to the <number> basic data type.

interface SVGNumber  {
  attribute float value;  // in user units

  // If this attribute or style property currently is being animated,
  // animatedValue reflects the current animated value of the 
  // attribute or style property.
  // Otherwise, when not animated, it will equal 'value'
  readonly attribute float animatedValue;  // in user units
};

3.2.7 Interface SVGRect

Rectangles are defined as consisting of a (x,y) coordinate pair identifying a minimum X value, a minimum Y value, and a width and height, which are usually constrained to be non-negative.

interface SVGRect  {
  attribute SVGNumber x;
  attribute SVGNumber y;
  attribute SVGNumber width;
  attribute SVGNumber height;

};