SVGTextContentElement: getRotationOfChar() 方法

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2015 年 7 月⁩以來,各瀏覽器均已提供此特性。

SVGTextContentElement 介面的 getRotationOfChar() 方法,表示一個排印字元的旋轉角度。

語法

js
getRotationOfChar(index)

引數

index

一個 integer;字元的索引。

返回值

一個浮點數;字元的旋轉角度(以度為單位)。

異常

IndexSizeError DOMException

如果 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

瀏覽器相容性

另見