SVGTextContentElement: getRotationOfChar() 方法
SVGTextContentElement 接口的 getRotationOfChar() 方法,表示一个排印字符的旋转角度。
语法
js
getRotationOfChar(index)
参数
index-
一个
integer;字符的索引。
返回值
一个浮点数;字符的旋转角度(以度为单位)。
异常
IndexSizeErrorDOMException-
如果
index处未找到字符,则抛出异常。
示例
获取字符的旋转角度
html
<svg width="200" height="100">
<text id="exampleText" x="10" y="40" writing-mode="vertical-rl">
Hello, SVG
</text>
</svg>
js
const textElement = document.getElementById("exampleText");
// Get the rotation of the first character "H"
const rotation = textElement.getRotationOfChar(0);
console.log(extent); // Output: 90
规范
| 规范 |
|---|
| Scalable Vector Graphics (SVG) 2 # __svg__SVGTextContentElement__getRotationOfChar |
浏览器兼容性
加载中…