如果我有聯SVG,包括已縮放的元素...如何使用JavaScript獲取縮放SVG元素的寬度?
<g transform="scale(sX,sY)">
<rect id="myElement" x="107" y="32" width="245" height="31" stroke="#C6C3C6" stroke-width="1px" />
</g>
...或處於<svg>
元件與viewBox
屬性:
<svg viewBox="20 20 5000 1230">
<g transform="scale(sX,sY)">
<rect id="myElement" x="107" y="32" width="245" height="31" stroke="#C6C3C6" stroke-width="1px" />
</g>
<svg>
...我怎樣才能以編程的方式找到myElement
像素的新縮放寬度 - 無需手動檢測縮放比例和數學運算?到目前爲止myElement.getBBox().width
返回245
而不考慮縮放。
@Richard JP Le Guen感謝您的賞金。 – rajkamal 2012-03-08 05:51:23