SVGTransform:setRotate() 方法
SVGTransform
接口的 setRotate()
方法将变换类型设置为 SVG_TRANSFORM_ROTATE
,其中参数 angle
定义了旋转角度,参数 cx
和 cy
定义了可选的旋转中心。
语法
js
setRotate(angle, cx, cy)
参数
返回值
无(undefined
)。
异常
NoModificationAllowedError
DOMException
-
如果属性或
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 |
浏览器兼容性
加载中…