SVGTransform:setRotate() 方法
SVGTransform 介面的 setRotate() 方法將變換型別設定為 SVG_TRANSFORM_ROTATE,其中引數 angle 定義了旋轉角度,引數 cx 和 cy 定義了可選的旋轉中心。
語法
js
setRotate(angle, cx, cy)
引數
返回值
無(undefined)。
異常
NoModificationAllowedErrorDOMException-
如果屬性或
SVGTransform物件是隻讀的,則丟擲此異常。
示例
旋轉 SVG 元素
js
// Select an SVG element and create a transform object
const svgElement = document.querySelector("svg");
const transform = svgElement.createSVGTransform();
// Set a rotation of 45 degrees
transform.setRotate(45, 0, 0);
// Output the rotation angle
console.log(`Rotation Angle: ${transform.angle}`); // Output: 45
規範
| 規範 |
|---|
| Scalable Vector Graphics (SVG) 2 # __svg__SVGTransform__setRotate |
瀏覽器相容性
載入中…