DOMMatrixReadOnly: rotate() method
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.
Note: This feature is available in Web Workers.
Phương thức rotate() của giao diện DOMMatrixReadOnly trả về một DOMMatrix mới được tạo bằng cách xoay ma trận nguồn quanh từng trục theo số độ được chỉ định. Ma trận gốc không bị thay đổi.
Để thay đổi ma trận khi xoay, hãy xem DOMMatrix.rotateSelf().
Cú pháp
rotate()
rotate(rotX)
rotate(rotX, rotY)
rotate(rotX, rotY, rotZ)
Tham số
rotX-
Một số; tọa độ x của vectơ biểu thị trục xoay. Nếu khác không,
is2Dlà false. rotYOptional-
Một số; tọa độ y của vectơ biểu thị trục xoay. Nếu khác không,
is2Dlà false. rotZOptional-
Một số; tọa độ z của vectơ biểu thị trục xoay.
Nếu chỉ truyền rotX, thì rotX được dùng làm giá trị cho tọa độ z, và cả tọa độ x lẫn y đều được đặt thành không.
Giá trị trả về
Một DOMMatrix.
Ví dụ
const matrix = new DOMMatrix(); // tạo một ma trận
console.log(matrix.toString());
// output: "matrix(1, 0, 0, 1, 0, 0)"
const rotated = matrix.rotate(30); // xoay và gán
console.log(matrix.toString()); // ma trận gốc không thay đổi
// output: "matrix(1, 0, 0, 1, 0, 0)"
console.log(rotated.toString());
// output: "matrix(0.866, 0.5, -0.5, 0.866, 0, 0)"
Thông số kỹ thuật
| Specification |
|---|
| Geometry Interfaces Module Level 1> # dom-dommatrixreadonly-rotate> |
Tương thích trình duyệt
Xem thêm
DOMMatrix.rotateSelf()DOMMatrixReadOnly.rotateAxisAngle()DOMMatrixReadOnly.rotateFromVector()- CSS
transformproperty androtate3d()function - CSS
rotateproperty - CSS transforms module
- SVG
transformattribute CanvasRenderingContext2Dinterface androtate()method