如何获得 JSFL 中符号的描边边界?
Actionscript 中的 DisplayObject.getBounds 返回包含笔划的对象的边界。 JSFL 中 SymbolInstance 的 left、top、width、height 属性似乎不包含笔画。这是我发现从 JSFL 获取符号边界的唯一方法。还有别的办法吗?
DisplayObject.getBounds in actionscript returns the bounds of the object with the strokes included. The left, top, width, height properties of a SymbolInstance in JSFL don't seem to include the strokes. That's the only way I've found to get the bounds of a symbol from JSFL. Is there another way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在寻找
Shape
上的Edge
对象。Edge
有一个Stroke
对象,该对象具有thickness
属性。您必须遍历所有形状及其所有边缘以确定最终边界(如果您确信所有边缘具有相同的厚度,则只需检查一个)。
You are looking for the
Edge
object on aShape
. TheEdge
has aStroke
object that has athickness
property.You will have to loop over all the shapes and all of their edges to determine final bounds (if you are confident that all the edges have the same thickness, just check one).
当涉及到获取对象的边界时,JSFL 的笔划宽度为 0。
我能想到的唯一方法是编辑符号,选择形状,然后
1.) 获取笔画大小并将其值的 1/2 添加到计算中,或者
2.) 将笔划转换为填充(对于复杂的轮廓来说不可靠)
如果您只想包含笔划但精确的大小并不重要,您可以在 getBounds 的结果中任意添加一些像素。
Strokes have 0 width to JSFL, when it comes to getting the bounds of an object.
The only method I can think of is to edit the symbol, select the shape, and either
1.) get the stroke size and add 1/2 of its value to your calculation, or
2.) convert the stroke to a fill (unreliable for complex outlines)
If you only wish to include the strokes but exact sizing is not crucial, you can just arbitrarily add some pixels to the result of getBounds.