SVGAngle
The SVGAngle
interface is used to represent a value that can be an <angle>
or <number>
value. An SVGAngle
reflected through the animVal
attribute is always read only.
An SVGAngle
object can be designated as read only, which means that attempts to modify the object will result in an exception being thrown.
An SVGAngle
object can be associated with a particular element. The associated element is used to determine which element's content attribute to update if the object reflects an attribute. Unless otherwise described, an SVGAngle
object is not associated with any element.
Every SVGAngle
object operates in one of two modes:
-
Reflect the base value of a reflected animatable attribute (being exposed through the
baseVal
member of anSVGAnimatedAngle
), -
Be detached, which is the case for
SVGAngle
objects created withSVGSVGElement.createSVGAngle()
.
Constants
SVG_ANGLETYPE_UNKNOWN
-
Some unknown type of value.
SVG_ANGLETYPE_UNSPECIFIED
-
A unitless
<number>
interpreted as a value in degrees. SVG_ANGLETYPE_DEG
-
An
<angle>
with adeg
unit. SVG_ANGLETYPE_RAD
-
An
<angle>
with arad
unit. SVG_ANGLETYPE_GRAD
-
An
<angle>
with agrad
unit.
Properties
unitType
-
The type of the value as specified by one of the
SVG_ANGLETYPE_*
constants defined on this interface. value
-
The value as a floating point value, in user units. Setting this attribute will cause
valueInSpecifiedUnits
andvalueAsString
to be updated automatically to reflect this setting.Exceptions on setting: A
DOMException
with codeNO_MODIFICATION_ALLOWED_ERR
is raised when the length corresponds to a read-only attribute, or when the object itself is read-only. valueInSpecifiedUnits
-
The value as a floating point value, in the units expressed by
unitType
. Setting this attribute will causevalue
andvalueAsString
to be updated automatically to reflect this setting.Exceptions on setting: A
DOMException
with codeNO_MODIFICATION_ALLOWED_ERR
is raised when the length corresponds to a read-only attribute, or when the object itself is read-only. valueAsString
-
The value as a
DOMString
value, in the units expressed byunitType
. Setting this attribute will causevalue
,valueInSpecifiedUnits
, andunitType
to be updated automatically to reflect this setting.Exceptions on setting:
A
DOMException
with codeSYNTAX_ERR
is raised if the assigned string cannot be parsed as a valid<angle>
.A
DOMException
with codeNO_MODIFICATION_ALLOWED_ERR
is raised when the length corresponds to a read-only attribute, or when the object itself is read-only.
Methods
newValueSpecifiedUnits
-
Reset the value as a number with an associated unitType, thereby replacing the values for all of the attributes on the object.
Exceptions:
- A
DOMException
with codeNOT_SUPPORTED_ERR
is raised ifunitType
isSVG_ANGLETYPE_UNKNOWN
or not a valid unit type constant (one of the otherSVG_ANGLETYPE_*
constants defined on this interface). - A
DOMException
with codeNO_MODIFICATION_ALLOWED_ERR
is raised when the length corresponds to a read only attribute or when the object itself is read only.
- A
convertToSpecifiedUnits
-
Preserve the same underlying stored value, but reset the stored unit identifier to the given
unitType
. Object attributesunitType
,valueInSpecifiedUnits
, andvalueAsString
might be modified as a result of this method.
Specifications
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
SVGAngle |
1 |
12 |
1.5 |
9 |
≤12.1 |
3 |
≤37 |
18 |
4 |
≤12.1 |
1 |
1.0 |
convertToSpecifiedUnits |
1 |
12 |
1.5 |
9 |
≤12.1 |
3 |
≤37 |
18 |
4 |
≤12.1 |
1 |
1.0 |
newValueSpecifiedUnits |
1 |
12 |
1.5 |
9 |
≤12.1 |
3 |
≤37 |
18 |
4 |
≤12.1 |
1 |
1.0 |
unitType |
1 |
12 |
1.5 |
9 |
≤12.1 |
3 |
≤37 |
18 |
4 |
≤12.1 |
1 |
1.0 |
value |
1 |
12 |
1.5 |
9 |
≤12.1 |
3 |
≤37 |
18 |
4 |
≤12.1 |
1 |
1.0 |
valueAsString |
1 |
12 |
1.5 |
9 |
≤12.1 |
3 |
≤37 |
18 |
4 |
≤12.1 |
1 |
1.0 |
valueInSpecifiedUnits |
1 |
12 |
1.5 |
9 |
≤12.1 |
3 |
≤37 |
18 |
4 |
≤12.1 |
1 |
1.0 |
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/SVGAngle