dojo 中 getBoundingBox() 的文档说:
返回形状的边界框。一个
文本形状是基于点的对象,因此
它没有定义边界框。
我不明白。 Web 矢量图形的任何合理实现都包括文本对象的边界框(即 raphaelJS 和 jQuery SVG)!这里,“基于点的对象”是什么意思?
我没有找到 Group 对象的边界框的引用,但是当使用最新的 Dojo 版本时,getBoundingbox
也为 Groups 返回 null
我可以自己轻松地为矩形做边界框,但我需要边界框的唯一真正有问题的形状是组和文本。
我结束了热补丁 dojo,如下所示:
dojox.gfx.Text.prototype.getBoundingBox = function() { return this.rawNode.getBBox();});
dojox.gfx.Group.prototype.getBoundingBox = function() { return this.rawNode.getBBox();});
这当然仅适用于 SVG 输出前端。
但我想知道,我是否错过了什么?有更好的方法吗?
The documentation for getBoundingBox() in dojo says:
Returns a bounding box of a shape. A
text shape is a point-based object, so
it doesn't define a bounding box.
I don't get it. Any sane implementation of vector graphics for the web includes bounding box for text objects (raphaelJS and jQuery SVG that is)! Here, what does "a point based object" mean?
I found no reference for a bounding box for Group object, but when using the latest Dojo version, getBoundingbox
returns null
for Groups as well
I can easily do bounding box for rectangle myself, but the only really problematic shapes I need bounding box for are the Group and the Text.
I ended hotpatching dojo like:
dojox.gfx.Text.prototype.getBoundingBox = function() { return this.rawNode.getBBox();});
dojox.gfx.Group.prototype.getBoundingBox = function() { return this.rawNode.getBBox();});
Which will of course work only for the SVG output front end.
But I wonder, am I missing something? Is there a better way to do that?
发布评论
评论(1)
这个问题与 此错误修复?对我来说听起来很像。它是
7 个月前由 pruzand 更改
并标记为已修复http://bugs。 dojotoolkit.org/ticket/7019
更新2012-07-24:我下载了release-1.8.0rc1 本地并设置 已解决的工单中的相同测试。这确实已在 1.8 中得到修复,并且 getBoundingBox 在组上返回 null 的问题已按照票证中所述得到解决。测试脚本成功返回:
同样,根据 这篇 twitter 帖子,1.8 到期了一两周后发布。
Is this problem related to this bug fix? Sounds like it to me. It was
Changed 7 months ago by pruzand
and marked as fixedhttp://bugs.dojotoolkit.org/ticket/7019
Update 2012-07-24: I downloaded release-1.8.0rc1 locally and setup the same test in the resolved ticket. This indeed has been fixed in 1.8 and getBoundingBox returning null on groups is resolved as stated in the ticket. The test script successfully returns:
Also for what it's worth, according to this twitter post, 1.8 is due to be released in a week or two.