SFML community forums

General => Feature requests => Topic started by: Deathbeam on May 20, 2014, 10:28:58 am

Title: Operators for IntRect and FloatRect
Post by: Deathbeam on May 20, 2014, 10:28:58 am
I am not sure if they are in official version, but in SFML.NET they are missing. Atleast operators == and != should be there. I can make pull request for it.
Title: Re: Operators for IntRect and FloatRect
Post by: Laurent on May 20, 2014, 11:14:45 am
They are in C++ version (it's easy to check...).
Title: Re: Operators for IntRect and FloatRect
Post by: Deathbeam on May 20, 2014, 04:53:41 pm
It is not that easy, becouse I am totally unexperienced in C++ (and also lazy, easier for me is to ask). Okay, made pull request for that missing operators then: https://github.com/SFML/SFML.Net/pull/55
Title: Re: Operators for IntRect and FloatRect
Post by: ChronicRat on May 30, 2014, 11:49:58 am
How about shrink/expand methods? It can be useful.
Title: Re: Operators for IntRect and FloatRect
Post by: Laurent on May 30, 2014, 12:16:02 pm
Quote
How about shrink/expand methods? It can be useful.
Useful for what?
Title: Re: Operators for IntRect and FloatRect
Post by: ChronicRat on May 30, 2014, 04:31:17 pm
If you need increase or decrease size of rectangle, just for code beauty. =) For me - it is useful.

template<typename T>
inline void sf::Rect<T>::shrink(T val)
{
    left += val;
    top += val;
    width -= val;
    height -= val;
}
 
Title: Re: Operators for IntRect and FloatRect
Post by: Deathbeam on May 30, 2014, 07:05:31 pm
If you need increase or decrease size of rectangle, just for code beauty. =) For me - it is useful.

template<typename T>
inline void sf::Rect<T>::shrink(T val)
{
    left += val;
    top += val;
    width -= val;
    height -= val;
}
 
Usefull? I know tons of usefull Vector and Rectangle functions but I still do not think that they should be implemented to SFML. Like
Union, Inflate, Center
 
for Rectangle and
Clamp, Dot, Direction, Distance, Catmull, Lerp, Hermite
 
etc... for Vector
Title: Re: Operators for IntRect and FloatRect
Post by: Hiura on May 30, 2014, 07:05:49 pm
For so small functions like this one it's simpler to let everyone implement it on his own way because otherwise we need a lot of different shrink functions to make everybody happy: your function reduce the sides by 2*val toward the center, some people would prefer only 1*val, others might want to reduce it toward the top left corner, ... With all these functions you get a bloated API and everybody get confused.  ;)
Title: Re: Operators for IntRect and FloatRect
Post by: ChronicRat on May 30, 2014, 07:50:59 pm
Just offered. =) By the way, i'm using GLM as math lib.