【发布时间】:2017-12-07 23:24:09
【问题描述】:
我正在使用 SVG.js 来绘制形状。其中一个形状需要是带有半径线的圆形,所以要获得这种行为,我在“g”元素内使用椭圆和线。
问题是,每当我引用那个 g 元素并尝试获取 bbox 时,我总是得到这样的值:
{
x: 0,
y: 0,
width: widthOfBox,
height: heightOfBox,
cx: widthOfBox/2,
cy: heightOfBox/2
}
x 和 y 不应为 0。
下面是有问题的元素,它显然不在 (0,0) 但似乎报告它是。
<g id="MLG1008" stroke="#000000" stroke-width="2" fill="#000000" transform="translate(100 200)" width="993.3559281546569" height="993.3559281546569" x="12.963409423828125" y="-290.0365905761719">
<ellipse id="MLEllipse1009" rx="496.67796407732845" ry="496.67796407732845" cx="496.67796407732845" cy="496.67796407732845" stroke="#000000" stroke-width="2"></ellipse>
<line id="MLLine1010" x1="496.67796407732845" y1="496.67796407732845" x2="801.6779640773284" y2="888.6779640773284" stroke="#000000" stroke-width="2"></line>
</g>
有没有办法定义 bbox 应该具有的值?或者设置 bbox() 查看的值的方法?
【问题讨论】:
标签: javascript html svg svg.js