Giter Club home page Giter Club logo

Comments (5)

bjorn avatar bjorn commented on July 29, 2024

It sounds definitely useful, but should these bounds also take into account object alignment and rotation then?

And I think bounding_rect might be a more fitting name, although the QGraphicsItem::boundingRect function does not include the item's position and rotation.

from rs-tiled.

aleokdev avatar aleokdev commented on July 29, 2024

OK, we could add a local_bounding_rect function that doesn't apply transformations for now, and then we could figure out rotations/position/etc on a global_bounding_rect function. Does that sound good?

from rs-tiled.

bjorn avatar bjorn commented on July 29, 2024

I'm not sure about the verbosity of these names. Wouldn't a bounding_rect that just returns the local rectangle be fine, and we could call the global one aabb? But if you prefer the explicit local/global I'm fine with that too.

Btw, you initially proposed only a global_bounds, so I asked whether that should then also take into account alignment and rotation because I thought those things should probably go together. I didn't mean to propose we also add a version returning a local rectangle. Maybe we should wait with adding that until there's an actual need.

from rs-tiled.

aleokdev avatar aleokdev commented on July 29, 2024

Btw, you initially proposed only a global_bounds, so I asked whether that should then also take into account alignment and rotation because I thought those things should probably go together. I didn't mean to propose we also add a version returning a local rectangle. Maybe we should wait with adding that until there's an actual need.

I didn't think of the implications of having global in the name. While it is true that global bounds should include rotation and alignment, it would complicate the implementation. There are times where rotation isn't applied to an object and it is useful to know its bounds, for instance when you want to obtain the width/height of a rect object quickly without having to match like in the example above, so I think having local in the name is best to differentiate between a possible global implementation later down the line.

from rs-tiled.

bjorn avatar bjorn commented on July 29, 2024

so I think having local in the name is best to differentiate between a possible global implementation later down the line.

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 (0,0), but for bottom-left alignment, that rectangle would need to have its top-left at (0,-height), right?

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.

from rs-tiled.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.