-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Easier way to obtain object bounds #301
Comments
It sounds definitely useful, but should these bounds also take into account object alignment and rotation then? And I think |
OK, we could add a |
I'm not sure about the verbosity of these names. Wouldn't a Btw, you initially proposed only a |
I didn't think of the implications of having |
Alright. What about alignment, though? I guess it is relevant even for a local bounding rectangle. For a rectangle with top-left alignment, the local bounding rect would have its top-left at Of course the problem with alignment is that it depends not only on the type of object, but also on the tileset object alignment property as well as on the map orientation. |
While refactoring my sokoban game to use this crate instead of my old fork, i realized a friction point that could be worked on.
Previously, to obtain an object's width or height, we could do the following:
However, since these members referred to deprecated members within the
<object>
tag, they were later removed. This means that to obtain the width/height of an object now, we need to match on the object's shape, check that it is an ellipse or rect, and obtain the width and height from there, something akin to:Doing this every time the user wants to obtain width/height of an object is a bit painful (and in this case also panics if the shape is anything but a rect or ellipse), so I propose a
object.global_bounds()
function of sorts that returns a rect including the position of the object as well as its actual width/height. I mean actual because previously width/height was not set for polygonal objects (since they are exclusively rect/ellipse members), but it could be useful to calculate them from the min/max point positions of the polygon.The text was updated successfully, but these errors were encountered: