SVGEllipseElement: ry 属性
SVGEllipseElement
接口的只读属性 ry
描述了椭圆在 y 轴上的半径,其类型为 SVGAnimatedLength
。它反映了 <ellipse>
元素上 ry
属性的计算值。
属性值可以是 <length>
、<percentage>
或 <number>
。SVGAnimatedLength.baseVal
的数值是以用户坐标系表示的椭圆在 y 轴上的半径。
值
一个 SVGAnimatedLength
对象。
示例
给定以下 SVG
html
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
<ellipse cx="50" cy="75" rx="30" ry="20" fill="blue" />
<ellipse cx="25%" cy="50%" rx="10%" ry="5%" fill="red" />
</svg>
我们可以访问 ry
属性的计算值
js
const ellipses = document.querySelectorAll("ellipse");
const ryPos0 = ellipses[0].ry;
const ryPos1 = ellipses[1].ry;
console.dir(ryPos0.baseVal.value); // output: 20
console.dir(ryPos1.baseVal.value); // output: 10 (5% of 200)
规范
规范 |
---|
Scalable Vector Graphics (SVG) 2 # __svg__SVGEllipseElement__ry |
浏览器兼容性
加载中…