The SVGLength interface correspond to the <length> basic data type.

MDN Reference

interface SVGLength {
    SVG_LENGTHTYPE_CM: 6;
    SVG_LENGTHTYPE_EMS: 3;
    SVG_LENGTHTYPE_EXS: 4;
    SVG_LENGTHTYPE_IN: 8;
    SVG_LENGTHTYPE_MM: 7;
    SVG_LENGTHTYPE_NUMBER: 1;
    SVG_LENGTHTYPE_PC: 10;
    SVG_LENGTHTYPE_PERCENTAGE: 2;
    SVG_LENGTHTYPE_PT: 9;
    SVG_LENGTHTYPE_PX: 5;
    SVG_LENGTHTYPE_UNKNOWN: 0;
    unitType: number;
    value: number;
    valueAsString: string;
    valueInSpecifiedUnits: number;
    convertToSpecifiedUnits(unitType: number): void;
    newValueSpecifiedUnits(
        unitType: number,
        valueInSpecifiedUnits: number,
    ): void;
}
Index

Properties

SVG_LENGTHTYPE_CM: 6
SVG_LENGTHTYPE_EMS: 3
SVG_LENGTHTYPE_EXS: 4
SVG_LENGTHTYPE_IN: 8
SVG_LENGTHTYPE_MM: 7
SVG_LENGTHTYPE_NUMBER: 1
SVG_LENGTHTYPE_PC: 10
SVG_LENGTHTYPE_PERCENTAGE: 2
SVG_LENGTHTYPE_PT: 9
SVG_LENGTHTYPE_PX: 5
SVG_LENGTHTYPE_UNKNOWN: 0
unitType: number

The unitType property of the SVGLength interface that represents type of the value as specified by one of the SVG_LENGTHTYPE_* constants defined on this interface.

MDN Reference

value: number

The value property of the SVGLength interface represents the floating point value of the <length> in user units.

MDN Reference

valueAsString: string

The valueAsString property of the SVGLength interface represents the <length>'s value as a string, in the units expressed by SVGLength.unitType.

MDN Reference

valueInSpecifiedUnits: number

The valueInSpecifiedUnits property of the SVGLength interface represents floating point value, in the units expressed by SVGLength.unitType.

MDN Reference

Methods

  • The convertToSpecifiedUnits() method of the SVGLength interface allows you to convert the length's value to the specified unit type.

    MDN Reference

    Parameters

    • unitType: number

    Returns void

  • The newValueSpecifiedUnits() method of the SVGLength interface resets the value as a number with an associated SVGLength.unitType, thereby replacing the values for all of the attributes on the object.

    MDN Reference

    Parameters

    • unitType: number
    • valueInSpecifiedUnits: number

    Returns void