DOMMatrix.webidl (8721B)
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 * 6 * The origin of this IDL file is 7 * https://drafts.fxtf.org/geometry/ 8 * 9 * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C 10 * liability, trademark and document use rules apply. 11 */ 12 13 [Exposed=(Window,Worker), 14 Serializable] 15 interface DOMMatrixReadOnly { 16 [Throws] 17 constructor(optional (UTF8String or sequence<unrestricted double> or DOMMatrixReadOnly) init); 18 19 [NewObject, Throws] static DOMMatrixReadOnly fromMatrix(optional DOMMatrixInit other = {}); 20 [NewObject, Throws] static DOMMatrixReadOnly fromFloat32Array(Float32Array array32); 21 [NewObject, Throws] static DOMMatrixReadOnly fromFloat64Array(Float64Array array64); 22 23 24 // These attributes are simple aliases for certain elements of the 4x4 matrix 25 readonly attribute unrestricted double a; 26 readonly attribute unrestricted double b; 27 readonly attribute unrestricted double c; 28 readonly attribute unrestricted double d; 29 readonly attribute unrestricted double e; 30 readonly attribute unrestricted double f; 31 32 readonly attribute unrestricted double m11; 33 readonly attribute unrestricted double m12; 34 readonly attribute unrestricted double m13; 35 readonly attribute unrestricted double m14; 36 readonly attribute unrestricted double m21; 37 readonly attribute unrestricted double m22; 38 readonly attribute unrestricted double m23; 39 readonly attribute unrestricted double m24; 40 readonly attribute unrestricted double m31; 41 readonly attribute unrestricted double m32; 42 readonly attribute unrestricted double m33; 43 readonly attribute unrestricted double m34; 44 readonly attribute unrestricted double m41; 45 readonly attribute unrestricted double m42; 46 readonly attribute unrestricted double m43; 47 readonly attribute unrestricted double m44; 48 49 // Immutable transform methods 50 DOMMatrix translate(optional unrestricted double tx = 0, 51 optional unrestricted double ty = 0, 52 optional unrestricted double tz = 0); 53 [NewObject] DOMMatrix scale(optional unrestricted double scaleX = 1, 54 optional unrestricted double scaleY, 55 optional unrestricted double scaleZ = 1, 56 optional unrestricted double originX = 0, 57 optional unrestricted double originY = 0, 58 optional unrestricted double originZ = 0); 59 [NewObject] DOMMatrix scaleNonUniform(optional unrestricted double scaleX = 1, 60 optional unrestricted double scaleY = 1); 61 DOMMatrix scale3d(optional unrestricted double scale = 1, 62 optional unrestricted double originX = 0, 63 optional unrestricted double originY = 0, 64 optional unrestricted double originZ = 0); 65 [NewObject] DOMMatrix rotate(optional unrestricted double rotX = 0, 66 optional unrestricted double rotY, 67 optional unrestricted double rotZ); 68 [NewObject] DOMMatrix rotateFromVector(optional unrestricted double x = 0, 69 optional unrestricted double y = 0); 70 [NewObject] DOMMatrix rotateAxisAngle(optional unrestricted double x = 0, 71 optional unrestricted double y = 0, 72 optional unrestricted double z = 0, 73 optional unrestricted double angle = 0); 74 DOMMatrix skewX(optional unrestricted double sx = 0); 75 DOMMatrix skewY(optional unrestricted double sy = 0); 76 [NewObject, Throws] DOMMatrix multiply(optional DOMMatrixInit other = {}); 77 DOMMatrix flipX(); 78 DOMMatrix flipY(); 79 DOMMatrix inverse(); 80 81 // Helper methods 82 readonly attribute boolean is2D; 83 readonly attribute boolean isIdentity; 84 DOMPoint transformPoint(optional DOMPointInit point = {}); 85 [Throws] Float32Array toFloat32Array(); 86 [Throws] Float64Array toFloat64Array(); 87 [Exposed=Window, Throws] stringifier; 88 [Default] object toJSON(); 89 }; 90 91 [Exposed=(Window,Worker), 92 Serializable, 93 LegacyWindowAlias=WebKitCSSMatrix] 94 interface DOMMatrix : DOMMatrixReadOnly { 95 [Throws] 96 constructor(optional (UTF8String or sequence<unrestricted double> or DOMMatrixReadOnly) init); 97 98 [NewObject, Throws] static DOMMatrix fromMatrix(optional DOMMatrixInit other = {}); 99 [NewObject, Throws] static DOMMatrix fromFloat32Array(Float32Array array32); 100 [NewObject, Throws] static DOMMatrix fromFloat64Array(Float64Array array64); 101 102 103 // These attributes are simple aliases for certain elements of the 4x4 matrix 104 inherit attribute unrestricted double a; 105 inherit attribute unrestricted double b; 106 inherit attribute unrestricted double c; 107 inherit attribute unrestricted double d; 108 inherit attribute unrestricted double e; 109 inherit attribute unrestricted double f; 110 111 inherit attribute unrestricted double m11; 112 inherit attribute unrestricted double m12; 113 inherit attribute unrestricted double m13; 114 inherit attribute unrestricted double m14; 115 inherit attribute unrestricted double m21; 116 inherit attribute unrestricted double m22; 117 inherit attribute unrestricted double m23; 118 inherit attribute unrestricted double m24; 119 inherit attribute unrestricted double m31; 120 inherit attribute unrestricted double m32; 121 inherit attribute unrestricted double m33; 122 inherit attribute unrestricted double m34; 123 inherit attribute unrestricted double m41; 124 inherit attribute unrestricted double m42; 125 inherit attribute unrestricted double m43; 126 inherit attribute unrestricted double m44; 127 128 // Mutable transform methods 129 [Throws] DOMMatrix multiplySelf(optional DOMMatrixInit other = {}); 130 [Throws] DOMMatrix preMultiplySelf(optional DOMMatrixInit other = {}); 131 DOMMatrix translateSelf(optional unrestricted double tx = 0, 132 optional unrestricted double ty = 0, 133 optional unrestricted double tz = 0); 134 DOMMatrix scaleSelf(optional unrestricted double scaleX = 1, 135 optional unrestricted double scaleY, 136 optional unrestricted double scaleZ = 1, 137 optional unrestricted double originX = 0, 138 optional unrestricted double originY = 0, 139 optional unrestricted double originZ = 0); 140 DOMMatrix scale3dSelf(optional unrestricted double scale = 1, 141 optional unrestricted double originX = 0, 142 optional unrestricted double originY = 0, 143 optional unrestricted double originZ = 0); 144 DOMMatrix rotateSelf(optional unrestricted double rotX = 0, 145 optional unrestricted double rotY, 146 optional unrestricted double rotZ); 147 DOMMatrix rotateFromVectorSelf(optional unrestricted double x = 0, 148 optional unrestricted double y = 0); 149 DOMMatrix rotateAxisAngleSelf(optional unrestricted double x = 0, 150 optional unrestricted double y = 0, 151 optional unrestricted double z = 0, 152 optional unrestricted double angle = 0); 153 DOMMatrix skewXSelf(optional unrestricted double sx = 0); 154 DOMMatrix skewYSelf(optional unrestricted double sy = 0); 155 DOMMatrix invertSelf(); 156 [Exposed=Window, Throws] DOMMatrix setMatrixValue(UTF8String transformList); 157 }; 158 159 dictionary DOMMatrix2DInit { 160 unrestricted double a; 161 unrestricted double b; 162 unrestricted double c; 163 unrestricted double d; 164 unrestricted double e; 165 unrestricted double f; 166 unrestricted double m11; 167 unrestricted double m12; 168 unrestricted double m21; 169 unrestricted double m22; 170 unrestricted double m41; 171 unrestricted double m42; 172 }; 173 174 dictionary DOMMatrixInit : DOMMatrix2DInit { 175 unrestricted double m13 = 0; 176 unrestricted double m14 = 0; 177 unrestricted double m23 = 0; 178 unrestricted double m24 = 0; 179 unrestricted double m31 = 0; 180 unrestricted double m32 = 0; 181 unrestricted double m33 = 1; 182 unrestricted double m34 = 0; 183 unrestricted double m43 = 0; 184 unrestricted double m44 = 1; 185 boolean is2D; 186 };