17cupsofcoffee / tetra

🎮 A simple 2D game framework written in Rust
MIT License
909 stars 63 forks source link

Add Rectangle::union (or something like it) #242

Closed 17cupsofcoffee closed 3 years ago

17cupsofcoffee commented 3 years ago

Summary:

There should be a method on Rectangle that gives you the union of two rectangles (i.e. a rectangle that surrounds them both).

The text caching functionality already does this to calculate the text's bounds, it just needs pulling out into a seperate method.

Why is this needed?

It's handy, and people have asked for it.

BoxyUwU commented 3 years ago

My first thought upon reading "union of two rectangles" was a rectangle that is the overlap of two rectangles x) I dont know if others would have that first thought (im probably totally wrong but i bring it up because it might be useful to know when writing docs)

17cupsofcoffee commented 3 years ago

Yeah, I'm not sure about the naming either - I need to have a look at what other libraries call it :)

also union is a keyword lmao

BoxyUwU commented 3 years ago

r#union sounds like a great variable name

17cupsofcoffee commented 3 years ago

Added Rectangle::combine on the main branch :)