DOMMatrixReadOnly: scale3d()-Methode
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
Hinweis: Diese Funktion ist in Web Workers verfügbar.
Die scale3d()
-Methode der DOMMatrixReadOnly
-Schnittstelle erstellt eine neue Matrix, die das Ergebnis einer 3D-Skalierungstransformation ist, die auf die Matrix angewendet wird. Sie gibt eine neue DOMMatrix
zurück, die erstellt wird, indem die Quell-3D-Matrix anhand des angegebenen Skalierungsfaktors skaliert wird, zentriert auf den Ursprungspunkt, der durch die Ursprungsparameter angegeben wird, wobei der Standardursprung (0, 0, 0)
ist. Die Originalmatrix wird nicht verändert.
Um die Matrix zu ändern, während Sie sie 3D-skalieren, siehe DOMMatrix.scale3dSelf()
.
Syntax
DOMMatrixReadOnly.scale3d();
DOMMatrixReadOnly.scale3d(scale);
DOMMatrixReadOnly.scale3d(scale, originX);
DOMMatrixReadOnly.scale3d(scale, originX, originY);
DOMMatrixReadOnly.scale3d(scale, originX, originY, originZ);
Parameter
scale
-
Ein Multiplikator; der Skalierungswert. Wenn keine Skala angegeben wird, ist der Standardwert
1
. originX
Optional-
Eine x-Koordinate für den Ursprung der Transformation. Wenn kein Ursprung angegeben wird, ist der Standardwert
0
. originY
Optional-
Eine y-Koordinate für den Ursprung der Transformation. Wenn kein Ursprung angegeben wird, ist der Standardwert
0
. originZ
Optional-
Eine z-Koordinate für den Ursprung der Transformation. Wenn dieser Wert
0
ist, was der Standardwert ist, wenn nichts angegeben wird, könnte die resultierende Matrix nicht 3D sein.
Rückgabewert
Eine DOMMatrix
.
Beispiele
const matrix = new DOMMatrix();
console.log(matrix.toString()); // no transforms applied
// matrix(1, 0, 0, 1, 0, 0)
console.log(matrix.scale3d(2).toString());
/* matrix3d(
2, 0, 0, 0,
0, 2, 0, 0,
0, 0, 2, 0,
0, 0, 0, 1) */
console.log(matrix.scale3d(0.5, 25, 25, 1.25).toString());
/* matrix3d(
0.5, 0, 0, 0,
0, 0.5, 0, 0,
0, 0, 0.5, 0, 1
2.5, 12.5, 0.625, 1) */
console.log(matrix.toString()); // original matrix is unchanged
// matrix(1, 0, 0, 1, 0, 0)
Spezifikationen
Specification |
---|
Geometry Interfaces Module Level 1 # dom-dommatrixreadonly-scale3d |
Browser-Kompatibilität
BCD tables only load in the browser
Siehe auch
DOMMatrix.scale3dSelf()
DOMMatrixReadOnly.scale()
- CSS
transform
-Eigenschaft undscale3d()
- undmatrix3d()
-Funktionen - CSS transforms Modul
- SVG
transform
Attribut CanvasRenderingContext2D
-Schnittstelle mit der MethodeCanvasRenderingContext2D.transform()