Copyright © 2014 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved. W3C liability, trademark and document use rules apply.
This specification provides basic geometric interfaces to represent points, rectangles, quadrilaterals and transformation matrices that can be used by other modules or specifications.
CSS is a language for describing the rendering of structured documents (such as HTML and XML) on screen, on paper, in speech, etc.This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
The (archived) public mailing list public-fx@w3.org (see instructions) is preferred for discussion of this specification. When sending e-mail, please put the text “geometry” in the subject, preferably like this: “[geometry] …summary of comment…”
This document was produced by the CSS Working Group (part of the Style Activity) and the SVG Working Group (part of the Graphics Activity).
This document was produced by groups operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures (CSS) and a public list of any patent disclosures (SVG) made in connection with the deliverables of each group; these pages also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
This document is governed by the 1 August 2014 W3C Process Document.
The following features are at-risk, and may be dropped during the CR period:
This specification describes several geometry interfaces [WEBIDL] for the representation of points, rectangles, quadrilaterals and transformation matrices with the dimension of 3x2 and 4x4.
The SVG interfaces SVGPoint, SVGRect and SVGMatrix [SVG11] are aliasing the here defined interfaces in favor for common interfaces used by SVG, Canvas 2D Context [2DCONTEXT] and CSS Transforms [CSS3-TRANSFORMS].
A 2D or a 3D point can be represented by the following WebIDL interfaces:
[Constructor(unrestricted double x, unrestricted double y, unrestricted double z, unrestricted double w)] interface DOMPointReadOnly { readonly attribute unrestricted double /x" data-link-for=DOMPointReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dompointreadonly-dompoint-x title=x>x ; readonly attribute unrestricted double /y" data-link-for=DOMPointReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dompointreadonly-dompoint-y title=y>y ; readonly attribute unrestricted double /z" data-link-for=DOMPointReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dompointreadonly-dompoint-z title=z>z ; readonly attribute unrestricted double /w" data-link-for=DOMPointReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dompointreadonly-dompoint-w title=w>w ; DOMPoint /matrixtransform()" data-link-for=DOMPointReadOnly data-link-type=method href=#dom-dompointreadonly-matrixtransform title=matrixTransform()>matrixTransform (DOMMatrixReadOnly matrix); }; [Constructor(optional DOMPointInit point), Constructor(optional unrestricted double x = 0, optional unrestricted double y = 0, optional unrestricted double z = 0, optional unrestricted double w = 1)] interface DOMPoint : DOMPointReadOnly { inherit attribute unrestricted double /x" data-link-for=DOMPoint data-link-type=attribute data-type="unrestricted double " href=#dom-dompointreadonly-dompoint-x title=x>x ; inherit attribute unrestricted double /y" data-link-for=DOMPoint data-link-type=attribute data-type="unrestricted double " href=#dom-dompointreadonly-dompoint-y title=y>y ; inherit attribute unrestricted double /z" data-link-for=DOMPoint data-link-type=attribute data-type="unrestricted double " href=#dom-dompointreadonly-dompoint-z title=z>z ; inherit attribute unrestricted double /w" data-link-for=DOMPoint data-link-type=attribute data-type="unrestricted double " href=#dom-dompointreadonly-dompoint-w title=w>w ; }; dictionary DOMPointInit { unrestricted double x = 0; unrestricted double y = 0; unrestricted double z = 0; unrestricted double w = 1; };
The following algorithms assume that DOMPointReadOnly objects have the internal member variables x coordinate, y coordinate, z coordinate and w perspective. DOMPointReadOnly as well as the inheriting interface DOMPoint must be able to access and set the value of these variables.
An interface returning an DOMPointReadOnly object by an attribute or function may be able to modify internal member variable values. Such an interface must specify this ability explicitly in prose.
Internal member variables must not be exposed in any way.
The DOMPointReadOnly(x, y, z, w)
constructor, when invoked, must run the following steps:
The DOMPoint()
constructor, when invoked, must run the following steps:
x
dictionary member of point.
y
dictionary member of point.
z
dictionary member of point.
w
dictionary member of point.
The y attribute, on getting, must return the y coordinate value of the object it was invoked on. For the DOMPoint interface, setting the y attribute must set the y coordinate value of the object it was invoked on to the new value.
The z attribute, on getting, must return the z coordinate value of the object it was invoked on. For the DOMPoint interface, setting the z attribute must set the z coordinate value of the object it was invoked on to the new value.
The w attribute, on getting, must return the w perspective value of the object it was invoked on. For the DOMPoint interface, setting the w attribute must set the w perspective value of the object it was invoked on to the new value.
matrixTransform(matrix), when invoked, must run the following steps
matrixTransform() does not modify the current DOMPointReadOnly object and returns a new DOMPoint object.
In this example the method matrixTransform() on point is called with a DOMMatrix argument matrix.
var point = new DOMPoint(5, 4);
var matrix = new DOMMatrix(2, 0, 0, 2, 10, 10);
var transformedPoint = point.matrixTransform(matrix);
point creates a new DOMPoint object initialized to the same attribute values as point. This new DOMPoint is now scaled and the translated by matrix. This resulting transformPoint has the attribute values x: 20
and y: 18
.
For historical reasons, Window objects must also have a writable, configurable, non-enumerable property named SVGPoint
whose value is the DOMPoint interface object.
Objects implementing the DOMRectReadOnly interface represent a rectangle. The type of box is specified by the method or attribute that returns a DOMRect or DOMRectReadOnly object.
Rectangles have the following properties:
[Constructor(unrestricted double x = 0, unrestricted double y = 0, unrestricted double width = 0, unrestricted double height = 0)] interface DOMRect : DOMRectReadOnly { inherit attribute unrestricted double /x" data-link-for=DOMRect data-link-type=attribute data-type="unrestricted double " href=#dom-domrectreadonly-domrect-x title=x>x ; inherit attribute unrestricted double /y" data-link-for=DOMRect data-link-type=attribute data-type="unrestricted double " href=#dom-domrectreadonly-domrect-y title=y>y ; inherit attribute unrestricted double /width" data-link-for=DOMRect data-link-type=attribute data-type="unrestricted double " href=#dom-domrectreadonly-domrect-width title=width>width ; inherit attribute unrestricted double /height" data-link-for=DOMRect data-link-type=attribute data-type="unrestricted double " href=#dom-domrectreadonly-domrect-height title=height>height ; }; [Constructor(unrestricted double x, unrestricted double y, unrestricted double width, unrestricted double height)] interface DOMRectReadOnly { readonly attribute unrestricted double /x" data-link-for=DOMRectReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-domrectreadonly-domrect-x title=x>x ; readonly attribute unrestricted double /y" data-link-for=DOMRectReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-domrectreadonly-domrect-y title=y>y ; readonly attribute unrestricted double /width" data-link-for=DOMRectReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-domrectreadonly-domrect-width title=width>width ; readonly attribute unrestricted double /height" data-link-for=DOMRectReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-domrectreadonly-domrect-height title=height>height ; readonly attribute unrestricted double /top" data-link-for=DOMRectReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-domrectreadonly-domrect-top title=top>top ; readonly attribute unrestricted double /right" data-link-for=DOMRectReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-domrectreadonly-domrect-right title=right>right ; readonly attribute unrestricted double /bottom" data-link-for=DOMRectReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-domrectreadonly-domrect-bottom title=bottom>bottom ; readonly attribute unrestricted double /left" data-link-for=DOMRectReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-domrectreadonly-domrect-left title=left>left ; }; dictionary DOMRectInit { unrestricted double x = 0; unrestricted double y = 0; unrestricted double width = 0; unrestricted double height = 0; };
The following algorithms assume that DOMRectReadOnly objects have the internal member variables x coordinate, y coordinate, width dimension and height dimension. DOMRectReadOnly as well as the inheriting interface DOMRect must be able to access and set the value of these variables.
An interface returning an DOMRectReadOnly object by an attribute or function may be able to modify internal member variable values. Such an interface must specify this ability explicitly in prose.
Internal member variables must not be exposed in any way.
The DOMRectReadOnly(x, y, width, height)
constructor, when invoked, must run the following steps:
The DOMRect(x, y, width, height)
constructor, when invoked, must run the following steps:
The y attribute, on getting, it must return the y coordinate value of the object it was invoked on. For the DOMRect interface, setting the y attribute must set the y coordinate value of the object it was invoked on to the new value.
The width attribute, on getting, must return the width value of the object it was invoked on. For the DOMRect interface, setting the width attribute must set the width dimension value of the object it was invoked on to the new value.
The height attribute, on getting, must return the height value. For the DOMRect interface, setting the height attribute must set the height dimension value to the new value.
The top attribute, on getting, must return min(y coordinate, y coordinate + height dimension) of the object it was invoked on.
The right attribute, on getting, must return max(x coordinate, x coordinate + width dimension) of the object it was invoked on.
The bottom attribute, on getting, must return max(y coordinate, y coordinate + height dimension) of the object it was invoked on.
The left attribute, on getting, must return min(x coordinate, x coordinate + width dimension) of the object it was invoked on.
For historical reasons, Window objects must also have a writable, configurable, non-enumerable property named SVGRect whose value is the DOMRect interface object.
[NoInterfaceObject, ArrayClass] interface DOMRectList { readonly attribute unsigned long /length" data-link-for=DOMRectList data-link-type=attribute data-readonly="" data-type="unsigned long " href=#dom-domrectlist-length title=length>length ; getter DOMRect? /item()" data-link-for=DOMRectList data-link-type=method href=#dom-domrectlist-item title=item()>item (unsigned long index); };
The length attribute must return the total number of DOMRect objects associated with the object.
The item(index) method, when invoked, must return a null value when index is greater than or equal to the number of DOMRect objects associated with the DOMRectList. Otherwise, the DOMRect object at index must be returned. Indices are zero-based.
DOMRectList must be supported for legacy reasons. New interfaces must not use DOMRectList and may use Sequences [WEBIDL] instead.Objects implementing the DOMQuad interface represents a quadrilateral.
[Constructor(optional DOMPointInit p1, optional DOMPointInit p2, optional DOMPointInit p3, optional DOMPointInit p4), Constructor(optional DOMRectInit rect)] interface DOMQuad { [SameObject] readonly attribute DOMPoint /p1" data-link-for=DOMQuad data-link-type=attribute data-readonly="" data-type="DOMPoint " href=#dom-domquad-p1 title=p1>p1 ; [SameObject] readonly attribute DOMPoint /p2" data-link-for=DOMQuad data-link-type=attribute data-readonly="" data-type="DOMPoint " href=#dom-domquad-p2 title=p2>p2 ; [SameObject] readonly attribute DOMPoint /p3" data-link-for=DOMQuad data-link-type=attribute data-readonly="" data-type="DOMPoint " href=#dom-domquad-p3 title=p3>p3 ; [SameObject] readonly attribute DOMPoint /p4" data-link-for=DOMQuad data-link-type=attribute data-readonly="" data-type="DOMPoint " href=#dom-domquad-p4 title=p4>p4 ; [SameObject] readonly attribute DOMRectReadOnly /bounds" data-link-for=DOMQuad data-link-type=attribute data-readonly="" data-type="DOMRectReadOnly " href=#dom-domquad-bounds title=bounds>bounds ; };
The DOMQuad()
constructor, when invoked, must run the following steps:
Return a new DOMQuad with p1 set to point 1, p2 set to point 2, p3 set to point 3 and p4 set to point 4, and let the associated bounding rectangle be bounds.
Return a new DOMQuad with p1 set to point 1, p2 set to point 2, p3 set to point 3 and p4 set to point 4, and let the associated bounding rectangle be bounds.
Note: It is possible to pass DOMPoint/DOMPointReadOnly arguments as well. The passed arguments will be transformed to the correct object type internally following the WebIDL rules [WEBIDL].
The p2 attribute must return a DOMPoint that represents p2 of the quadrilateral it was invoked on. The author can modify the returned DOMPoint object, which directly affects the quadrilateral.
The p3 attribute must return a DOMPoint that represents p3 of the quadrilateral it was invoked on. The author can modify the returned DOMPoint object, which directly affects the quadrilateral.
The p4 attribute must return a DOMPoint that represents p4 of the quadrilateral it was invoked on. The author can modify the returned DOMPoint object, which directly affects the quadrilateral.
The bounds attribute must return the associated bounding rectangle of the quadrilateral it was invoked on.
DOMQuad objects have an associated bounding rectangle set to a DOMRectReadOnly object when created. DOMQuad objects must have read and write access to the internal member variables of the associated bounding rectangle. The associated bounding rectangle is live; whenever the objects for p1, p2, p3 or p4 change, the associated bounding rectangle must update its internal member variable values as appropriate to describe the new smallest bounding box of the four points.
The associated bounding rectangle is computed as follows:
In this example the DOMQuad constructor is called with arguments of type DOMPoint and DOMPointInit. Both arguments are accepted and can be used.
var point = new DOMPoint(2, 0);
var quad1 = new DOMQuad(point, {x: 12, y: 0}, {x: 2, y: 10}, {x: 12, y: 10});
The attribute values of the resulting DOMQuad quad1 above are also equal to the attribute values of the following DOMQuad quad2:
var rect = new DOMRect(2, 0, 10, 10);
var quad2 = new DOMQuad(rect);
This is an example of an irregular quadrilateral:
new DOMQuad({x: 40, y: 25}, {x: 180, y: 8}, {x: 210, y: 150}, {x: 10, y: 180});
The DOMMatrix and DOMMatrixReadOnly interfaces each represent a mathematical matrix with the purpose of describing transformations in a graphical context. The following sections describe the details of the interface.
A 4x4 matrix representing a DOMMatrix with items m11 to m44.
In the following sections, terms have the following meaning:
[Constructor(sequence<unrestricted double> numberSequence)] interface DOMMatrixReadOnly { // These attributes are simple aliases for certain elements of the 4x4 matrix readonly attribute unrestricted double /a" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-a title=a>a ; readonly attribute unrestricted double /b" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-b title=b>b ; readonly attribute unrestricted double /c" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-c title=c>c ; readonly attribute unrestricted double /d" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-d title=d>d ; readonly attribute unrestricted double /e" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-e title=e>e ; readonly attribute unrestricted double /f" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-f title=f>f ; readonly attribute unrestricted double /m11" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m11 title=m11>m11 ; readonly attribute unrestricted double /m12" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m12 title=m12>m12 ; readonly attribute unrestricted double /m13" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m13 title=m13>m13 ; readonly attribute unrestricted double /m14" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m14 title=m14>m14 ; readonly attribute unrestricted double /m21" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m21 title=m21>m21 ; readonly attribute unrestricted double /m22" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m22 title=m22>m22 ; readonly attribute unrestricted double /m23" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m23 title=m23>m23 ; readonly attribute unrestricted double /m24" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m24 title=m24>m24 ; readonly attribute unrestricted double /m31" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m31 title=m31>m31 ; readonly attribute unrestricted double /m32" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m32 title=m32>m32 ; readonly attribute unrestricted double /m33" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m33 title=m33>m33 ; readonly attribute unrestricted double /m34" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m34 title=m34>m34 ; readonly attribute unrestricted double /m41" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m41 title=m41>m41 ; readonly attribute unrestricted double /m42" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m42 title=m42>m42 ; readonly attribute unrestricted double /m43" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m43 title=m43>m43 ; readonly attribute unrestricted double /m44" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m44 title=m44>m44 ; readonly attribute boolean /is2d" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="boolean " href=#dom-dommatrixreadonly-is2d title=is2D>is2D ; readonly attribute boolean /isidentity" data-link-for=DOMMatrixReadOnly data-link-type=attribute data-readonly="" data-type="boolean " href=#dom-dommatrixreadonly-isidentity title=isIdentity>isIdentity ; // Immutable transform methods DOMMatrix /translate()" data-link-for=DOMMatrixReadOnly data-link-type=method href=#dom-dommatrixreadonly-translate title=translate()>translate (unrestricted double tx, unrestricted double ty, optional unrestricted double tz = 0); DOMMatrix /scale()" data-link-for=DOMMatrixReadOnly data-link-type=method href=#dom-dommatrixreadonly-scale title=scale()>scale (unrestricted double scale, optional unrestricted double originX = 0, optional unrestricted double originY = 0); DOMMatrix /scale3d()" data-link-for=DOMMatrixReadOnly data-link-type=method href=#dom-dommatrixreadonly-scale3d title=scale3d()>scale3d (unrestricted double scale, optional unrestricted double originX = 0, optional unrestricted double originY = 0, optional unrestricted double originZ = 0); DOMMatrix /scalenonuniform()" data-link-for=DOMMatrixReadOnly data-link-type=method href=#dom-dommatrixreadonly-scalenonuniform title=scaleNonUniform()>scaleNonUniform (unrestricted double scaleX, optional unrestricted double scaleY = 1, optional unrestricted double scaleZ = 1, optional unrestricted double originX = 0, optional unrestricted double originY = 0, optional unrestricted double originZ = 0); DOMMatrix /rotate()" data-link-for=DOMMatrixReadOnly data-link-type=method href=#dom-dommatrixreadonly-rotate title=rotate()>rotate (unrestricted double angle, optional unrestricted double originX = 0, optional unrestricted double originY = 0); DOMMatrix /rotatefromvector()" data-link-for=DOMMatrixReadOnly data-link-type=method href=#dom-dommatrixreadonly-rotatefromvector title=rotateFromVector()>rotateFromVector (unrestricted double x, unrestricted double y); DOMMatrix /rotateaxisangle()" data-link-for=DOMMatrixReadOnly data-link-type=method href=#dom-dommatrixreadonly-rotateaxisangle title=rotateAxisAngle()>rotateAxisAngle (unrestricted double x, unrestricted double y, unrestricted double z, unrestricted double angle); DOMMatrix /skewx()" data-link-for=DOMMatrixReadOnly data-link-type=method href=#dom-dommatrixreadonly-skewx title=skewX()>skewX (unrestricted double sx); DOMMatrix /skewy()" data-link-for=DOMMatrixReadOnly data-link-type=method href=#dom-dommatrixreadonly-skewy title=skewY()>skewY (unrestricted double sy); DOMMatrix /multiply()" data-link-for=DOMMatrixReadOnly data-link-type=method href=#dom-dommatrixreadonly-multiply title=multiply()>multiply (DOMMatrix other); DOMMatrix /flipx()" data-link-for=DOMMatrixReadOnly data-link-type=method href=#dom-dommatrixreadonly-flipx title=flipX()>flipX (); DOMMatrix /flipy()" data-link-for=DOMMatrixReadOnly data-link-type=method href=#dom-dommatrixreadonly-flipy title=flipY()>flipY (); DOMMatrix /inverse()" data-link-for=DOMMatrixReadOnly data-link-type=method href=#dom-dommatrixreadonly-inverse title=inverse()>inverse (); DOMPoint /transformpoint()" data-link-for=DOMMatrixReadOnly data-link-type=method href=#dom-dommatrixreadonly-transformpoint title=transformPoint()>transformPoint (optional DOMPointInit point); Float32Array /tofloat32array()" data-link-for=DOMMatrixReadOnly data-link-type=method href=#dom-dommatrixreadonly-tofloat32array title=toFloat32Array()>toFloat32Array (); Float64Array /tofloat64array()" data-link-for=DOMMatrixReadOnly data-link-type=method href=#dom-dommatrixreadonly-tofloat64array title=toFloat64Array()>toFloat64Array (); stringifier; }; [Constructor, Constructor(DOMString transformList), Constructor(DOMMatrixReadOnly other), Constructor(Float32Array array32), Constructor(Float64Array array64), Constructor(sequence<unrestricted double> numberSequence)] interface DOMMatrix : DOMMatrixReadOnly { // These attributes are simple aliases for certain elements of the 4x4 matrix inherit attribute unrestricted double /a" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-a title=a>a ; inherit attribute unrestricted double /b" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-b title=b>b ; inherit attribute unrestricted double /c" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-c title=c>c ; inherit attribute unrestricted double /d" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-d title=d>d ; inherit attribute unrestricted double /e" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-e title=e>e ; inherit attribute unrestricted double /f" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-f title=f>f ; inherit attribute unrestricted double /m11" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m11 title=m11>m11 ; inherit attribute unrestricted double /m12" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m12 title=m12>m12 ; inherit attribute unrestricted double /m13" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m13 title=m13>m13 ; inherit attribute unrestricted double /m14" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m14 title=m14>m14 ; inherit attribute unrestricted double /m21" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m21 title=m21>m21 ; inherit attribute unrestricted double /m22" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m22 title=m22>m22 ; inherit attribute unrestricted double /m23" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m23 title=m23>m23 ; inherit attribute unrestricted double /m24" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m24 title=m24>m24 ; inherit attribute unrestricted double /m31" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m31 title=m31>m31 ; inherit attribute unrestricted double /m32" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m32 title=m32>m32 ; inherit attribute unrestricted double /m33" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m33 title=m33>m33 ; inherit attribute unrestricted double /m34" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m34 title=m34>m34 ; inherit attribute unrestricted double /m41" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m41 title=m41>m41 ; inherit attribute unrestricted double /m42" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m42 title=m42>m42 ; inherit attribute unrestricted double /m43" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m43 title=m43>m43 ; inherit attribute unrestricted double /m44" data-link-for=DOMMatrix data-link-type=attribute data-type="unrestricted double " href=#dom-dommatrixreadonly-dommatrix-m44 title=m44>m44 ; // Mutable transform methods DOMMatrix /multiplyself()" data-link-for=DOMMatrix data-link-type=method href=#dom-dommatrix-multiplyself title=multiplySelf()>multiplySelf (DOMMatrix other); DOMMatrix /premultiplyself()" data-link-for=DOMMatrix data-link-type=method href=#dom-dommatrix-premultiplyself title=preMultiplySelf()>preMultiplySelf (DOMMatrix other); DOMMatrix /translateself()" data-link-for=DOMMatrix data-link-type=method href=#dom-dommatrix-translateself title=translateSelf()>translateSelf (unrestricted double tx, unrestricted double ty, optional unrestricted double tz = 0); DOMMatrix /scaleself()" data-link-for=DOMMatrix data-link-type=method href=#dom-dommatrix-scaleself title=scaleSelf()>scaleSelf (unrestricted double scale, optional unrestricted double originX = 0, optional unrestricted double originY = 0); DOMMatrix /scale3dself()" data-link-for=DOMMatrix data-link-type=method href=#dom-dommatrix-scale3dself title=scale3dSelf()>scale3dSelf (unrestricted double scale, optional unrestricted double originX = 0, optional unrestricted double originY = 0, optional unrestricted double originZ = 0); DOMMatrix /scalenonuniformself()" data-link-for=DOMMatrix data-link-type=method href=#dom-dommatrix-scalenonuniformself title=scaleNonUniformSelf()>scaleNonUniformSelf (unrestricted double scaleX, optional unrestricted double scaleY = 1, optional unrestricted double scaleZ = 1, optional unrestricted double originX = 0, optional unrestricted double originY = 0, optional unrestricted double originZ = 0); DOMMatrix /rotateself()" data-link-for=DOMMatrix data-link-type=method href=#dom-dommatrix-rotateself title=rotateSelf()>rotateSelf (unrestricted double angle, optional unrestricted double originX = 0, optional unrestricted double originY = 0); DOMMatrix /rotatefromvectorself()" data-link-for=DOMMatrix data-link-type=method href=#dom-dommatrix-rotatefromvectorself title=rotateFromVectorSelf()>rotateFromVectorSelf (unrestricted double x, unrestricted double y); DOMMatrix /rotateaxisangleself()" data-link-for=DOMMatrix data-link-type=method href=#dom-dommatrix-rotateaxisangleself title=rotateAxisAngleSelf()>rotateAxisAngleSelf (unrestricted double x, unrestricted double y, unrestricted double z, unrestricted double angle); DOMMatrix /skewxself()" data-link-for=DOMMatrix data-link-type=method href=#dom-dommatrix-skewxself title=skewXSelf()>skewXSelf (unrestricted double sx); DOMMatrix /skewyself()" data-link-for=DOMMatrix data-link-type=method href=#dom-dommatrix-skewyself title=skewYSelf()>skewYSelf (unrestricted double sy); DOMMatrix /invertself()" data-link-for=DOMMatrix data-link-type=method href=#dom-dommatrix-invertself title=invertSelf()>invertSelf (); DOMMatrix /setmatrixvalue()" data-link-for=DOMMatrix data-link-type=method href=#dom-dommatrix-setmatrixvalue title=setMatrixValue()>setMatrixValue (DOMString transformList); };
The following algorithms assume that DOMMatrixReadOnly objects have the internal member variables m11 element, m12 element, m13 element, m14 element, m21 element, m22 element, m23 element, m24 element, m31 element, m32 element, m33 element, m34 element, m41 element, m42 element, m43 element, m44 element and is2D. DOMMatrixReadOnly as well as the inheriting interface DOMMatrix must be able to access and set the value of these variables.
An interface returning an DOMMatrixReadOnly object by an attribute or function may be able to modify internal member variable values. Such an interface must specify this ability explicitly in prose.
Internal member variables must not be exposed in any way.
The DOMMatrix and DOMMatrixReadOnly interfaces replace the SVGMatrix interface from SVG [SVG11].
For historical reasons, Window objects must also have a writable, configurable, non-enumerable property named SVGMatrix whose value is the DOMMatrix interface object.
The DOMMatrixReadOnly(sequence<unrestricted double> numberSequence)
constructor, when invoked, must run the following steps:
TypeError
exception.The DOMMatrix()
constructor, when invoked, must run the following steps:
TypeError
exception.TypeError
exception.TypeError
exception.The following attributes m11 to m44 correspond to the 16 items of the matrix interfaces. For the DOMMatrix interface, if the attributes m31, m32, m13, m23, m43, m14, m24, m34 are set to something else than 0 or m33, m44 are set to something else than 1 set is2D to false.
The m12 attribute, on getting, must return the m12 element value of the object it was invoked on. For the DOMMatrix interface, setting the m12 attribute must set the m12 element value of the object it was invoked on to the new value.
The m13 attribute, on getting, must return the m13 element value of the object it was invoked on. For the DOMMatrix interface, setting the m13 attribute must set the m13 element value of the object it was invoked on to the new value.
The m14 attribute, on getting, must return the m14 element value of the object it was invoked on. For the DOMMatrix interface, setting the m14 attribute must set the m14 element value of the object it was invoked on to the new value.
The m21 attribute, on getting, must return the m21 element value of the object it was invoked on. For the DOMMatrix interface, setting the m21 attribute must set the m21 element value of the object it was invoked on to the new value.
The m22 attribute, on getting, must return the m22 element value of the object it was invoked on. For the DOMMatrix interface, setting the m22 attribute must set the m22 element value of the object it was invoked on to the new value.
The m23 attribute, on getting, must return the m23 element value of the object it was invoked on. For the DOMMatrix interface, setting the m23 attribute must set the m23 element value of the object it was invoked on to the new value.
The m24 attribute, on getting, must return the m24 element value of the object it was invoked on. For the DOMMatrix interface, setting the m24 attribute must set the m24 element value of the object it was invoked on to the new value.
The m31 attribute, on getting, must return the m31 element value of the object it was invoked on. For the DOMMatrix interface, setting the m31 attribute must set the m31 element value of the object it was invoked on to the new value.
The m32 attribute, on getting, must return the m32 element value of the object it was invoked on. For the DOMMatrix interface, setting the m32 attribute must set the m32 element value of the object it was invoked on to the new value.
The m33 attribute, on getting, must return the m33 element value of the object it was invoked on. For the DOMMatrix interface, setting the m33 attribute must set the m33 element value of the object it was invoked on to the new value.
The m34 attribute, on getting, must return the m34 element value of the object it was invoked on. For the DOMMatrix interface, setting the m34 attribute must set the m34 element value of the object it was invoked on to the new value.
The m41 attribute, on getting, must return the m41 element value of the object it was invoked on. For the DOMMatrix interface, setting the m41 attribute must set the m41 element value of the object it was invoked on to the new value.
The m42 attribute, on getting, must return the m42 element value of the object it was invoked on. For the DOMMatrix interface, setting the m42 attribute must set the m42 element value of the object it was invoked on to the new value.
The m43 attribute, on getting, must return the m43 element value of the object it was invoked on. For the DOMMatrix interface, setting the m43 attribute must set the m43 element value of the object it was invoked on to the new value.
The m44 attribute, on getting, must return the m44 element value of the object it was invoked on. For the DOMMatrix interface, setting the m44 attribute must set the m44 element value of the object it was invoked on to the new value.
The a attribute is an alias to the m11 attribute.
The b attribute is an alias to the m12 attribute.
The c attribute is an alias to the m21 attribute.
The d attribute is an alias to the m22 attribute.
The e attribute is an alias to the m41 attribute.
The f attribute is an alias to the m42 attribute.
The following attributes provide status information about DOMMatrixReadOnly.
Every DOMMatrixReadOnly object must be flagged with a boolean is2D. This flag indicates that
is2D can never be set to true when it was set to false before on a DOMMatrix object with the exception of calling the setMatrixValue() method.
Returns the value of is2D.
The following methods do not modify the current matrix and return a new DOMMatrix object.
The current matrix is not modified.
The current matrix is not modified.
The current matrix is not modified.
The current matrix is not modified.
The current matrix is not modified.
The current matrix is not modified.
The current matrix is not modified.
The current matrix is not modified.
The current matrix is not modified.
The current matrix is not modified.
DOMMatrix(-1, 0, 0, 1, 0, 0)
.The current matrix is not modified.
DOMMatrix(1, 0, 0, -1, 0, 0)
.The current matrix is not modified.
The current matrix is not modified.
The following methods do not modify the current matrix.
Note: Even if is2D of the current matrix may return true, a 4x4 matrix multiplication must be performed if the z attribute of point is not 0 or the w attribute of point is not 1.
In this example, a matrix is created and several 2D transformation methods are called:
var matrix = new DOMMatrix();
matrix.scaleSelf(2);
matrix.translateSelf(20,20);
Calling matrix.toString()
returns the DOMString:
"matrix(2, 0, 0, 2, 20, 20)"
In the following example, a matrix is created and several 3D transformation methods are called:
var matrix = new DOMMatrix();
matrix.scale3dSelf(2);
For 3D operations, the stringifier returns a DOMString representing a 3D matrix.
Calling matrix.toString()
after the snippet above returns the DOMString:
"matrix3d(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1)"
The following methods modify the current matrix, so that each method returns the matrix where it was invoked on. The primary benefit of this is allowing content creators to chain method calls.
The following code example:
var matrix = new DOMMatrix();
matrix.translateSelf(20, 20);
matrix.scaleSelf(2);
matrix.translateSelf(-20, -20);
is equivalent to:
var matrix = new DOMMatrix();
matrix.translateSelf(20, 20).scaleSelf(2).translateSelf(-20, -20);
Note: Authors who use chained method calls are recommended to use mutable transformation methods to avoid unnecessary memory allocations due to creation of intermediate DOMMatrix objects in User Agents.
alpha
is the angle between the vector (1,0)T and (x,y)T in degrees [CSS3-TRANSFORMS].The following changes were made since the 26 June 2014 Last Call Public Working Draft.
The following changes were made since the 22 May 2014 First Public Working Draft.
The editors would like to thank Robert O’Callahan for contributing to this specification. Many thanks to Dean Jackson for his initial proposal of DOMMatrix. Thanks to Brian Birtles, Benoit Jacob, Cameron McCormack, Kari Pihkala, Adenilson Cavalcanti, Boris Zbarsky and Max Vujovic for their careful reviews, comments, and corrections.
Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification.
All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [RFC2119]
Examples in this specification are introduced with the words "for example"
or are set apart from the normative text with class="example"
,
like this:
This is an example of an informative example.
Informative notes begin with the word "Note" and are set apart from the
normative text with class="note"
, like this:
Note, this is an informative note.
Advisements are normative sections styled to evoke special attention and are
set apart from other normative text with <strong class="advisement">
, like
this:
UAs MUST provide an accessible alternative.
Conformance to this specification is defined for three conformance classes:
A style sheet is conformant to this specification if all of its statements that use syntax defined in this module are valid according to the generic CSS grammar and the individual grammars of each feature defined in this module.
A renderer is conformant to this specification if, in addition to interpreting the style sheet as defined by the appropriate specifications, it supports all the features defined by this specification by parsing them correctly and rendering the document accordingly. However, the inability of a UA to correctly render a document due to limitations of the device does not make the UA non-conformant. (For example, a UA is not required to render color on a monochrome monitor.)
An authoring tool is conformant to this specification if it writes style sheets that are syntactically correct according to the generic CSS grammar and the individual grammars of each feature in this module, and meet all other conformance requirements of style sheets as described in this module.
So that authors can exploit the forward-compatible parsing rules to assign fallback values, CSS renderers must treat as invalid (and ignore as appropriate) any at-rules, properties, property values, keywords, and other syntactic constructs for which they have no usable level of support. In particular, user agents must not selectively ignore unsupported component values and honor supported values in a single multi-value property declaration: if any value is considered invalid (as unsupported values must be), CSS requires that the entire declaration be ignored.
To avoid clashes with future CSS features, the CSS2.1 specification reserves a prefixed syntax for proprietary and experimental extensions to CSS.
Prior to a specification reaching the Candidate Recommendation stage in the W3C process, all implementations of a CSS feature are considered experimental. The CSS Working Group recommends that implementations use a vendor-prefixed syntax for such features, including those in W3C Working Drafts. This avoids incompatibilities with future changes in the draft.
Once a specification reaches the Candidate Recommendation stage, non-experimental implementations are possible, and implementors should release an unprefixed implementation of any CR-level feature they can demonstrate to be correctly implemented according to spec.
To establish and maintain the interoperability of CSS across implementations, the CSS Working Group requests that non-experimental CSS renderers submit an implementation report (and, if necessary, the testcases used for that implementation report) to the W3C before releasing an unprefixed implementation of any CSS features. Testcases submitted to W3C are subject to review and correction by the CSS Working Group.
Further information on submitting testcases and implementation reports can be found from on the CSS Working Group’s website at http://www.w3.org/Style/CSS/Test/. Questions should be directed to the public-css-testsuite@w3.org mailing list.
No properties defined.