cinder / Cinder

Cinder is a community-developed, free and open source library for professional-quality creative coding in C++.
http://libcinder.org
Other
5.27k stars 939 forks source link

Add coordinate accessors to Rect.h #2182

Closed IntellectualKitty closed 4 years ago

paulhoux commented 4 years ago

I don't think adding more accessors to the class is necessary. We already have getX1() and so on, and you can also directly access the member variables.

IntellectualKitty commented 4 years ago

The way that cinder::RectT is implemented is unnecessarily ambiguous and confusing. Every time I write new code using it, I have to go back to the header file to reference the names of member variables with their meaning:

    Vec2T       getUpperLeft() const    { return Vec2T( x1, y1 ); };
    Vec2T       getUpperRight() const   { return Vec2T( x2, y1 ); };
    Vec2T       getLowerRight() const   { return Vec2T( x2, y2 ); };
    Vec2T       getLowerLeft() const    { return Vec2T( x1, y2 ); };

For example, x1 is left, y2 is bottom, etc.

Adding specific coordinate accessors based on their meaning removes the ambiguity and confusion. And it also does so without breaking the existing interface.