文本和组节点的 dojox.gfx 边界框

发布于 2024-08-08 12:26:38 字数 645 浏览 10 评论 0 原文

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深居我梦 2024-08-15 12:26:38

我没有找到 Group 对象的边界框的引用,但是当使用最新的 Dojo 版本时,getBoundingbox 也会为 Groups 返回 null

这个问题与 此错误修复?对我来说听起来很像。它是 7 个月前由 pruzand 更改 并标记为已修复

http://bugs。 dojotoolkit.org/ticket/7019

更新2012-07-24:我下载了release-1.8.0rc1 本地并设置 已解决的工单中的相同测试。这确实已在 1.8 中得到修复,并且 getBoundingBox 在组上返回 null 的问题已按照票证中所述得到解决。测试脚本成功返回:

bbox of group: {"x":0,"y":2,"endX":238,"endY":379,"width":238,"height":377}
transformed bbox: [{"x":277.7302117816355,"y":152.5448441073243},{"x":512.114456998541,"y":193.87311039205372},{"x":446.64909401810826,"y":565.1456332776561},{"x":212.26484880120276,"y":523.8173669929267}]

同样,根据 这篇 twitter 帖子,1.8 到期了一两周后发布。

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

Is this problem related to this bug fix? Sounds like it to me. It was Changed 7 months ago by pruzand and marked as fixed

http://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:

bbox of group: {"x":0,"y":2,"endX":238,"endY":379,"width":238,"height":377}
transformed bbox: [{"x":277.7302117816355,"y":152.5448441073243},{"x":512.114456998541,"y":193.87311039205372},{"x":446.64909401810826,"y":565.1456332776561},{"x":212.26484880120276,"y":523.8173669929267}]

Also for what it's worth, according to this twitter post, 1.8 is due to be released in a week or two.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文