SFML community forums

General => Feature requests => Topic started by: MrOnlineCoder on June 11, 2017, 03:57:12 pm

Title: addColor method
Post by: MrOnlineCoder on June 11, 2017, 03:57:12 pm
Hello. In game, I often use some "flash" effects, or fading animations, where I change sprite/shape color like this:

sf::Color color = sprite.getColor();
color.a++;
sprite.setColor(color);
 

It will be very nice and useful if addColor method exists:
sprite.addColor(0,0,0,1);
 
Title: Re: addColor method
Post by: Laurent on June 11, 2017, 06:35:12 pm
And then? subColor, mulColor, divColor? addPosition, subPosition, mulScale, divScale, ...? And this big mess in all SFML drawable classes? Or even in all classes, since almost every member of every class supports arithmetic operations? :P
Title: Re: addColor method
Post by: Hapax on June 11, 2017, 08:33:54 pm
What's wrong with the normal colour addition?:
sf::Color color(255, 255, 255, 0);
color += sf::Color(0, 0, 0, 1);

So, for your example it would be just:
sprite.setColor(sprite.getColor() + sf::Color(0, 0, 0, 1));
Title: Re: addColor method
Post by: jamesL on June 12, 2017, 08:33:07 am
And then? ...  addPosition, subPosition ...? And this big mess in all SFML drawable classes?

isn't that what move is ?

https://www.sfml-dev.org/documentation/2.4.2/classsf_1_1Transformable.php#ab9ca691522f6ddc1a40406849b87c469
Title: Re: addColor method
Post by: Laurent on June 12, 2017, 09:00:51 am
Quote
isn't that what move is ?
That's right, move() should be removed.
Title: Re: addColor method
Post by: Phanoo on August 31, 2017, 10:01:16 am
Ideally, Laurent would like to remove everything until SFML isn't useable anymore  ;D ;D ;D
Title: Re: addColor method
Post by: DJuego on August 31, 2017, 12:38:40 pm
"The perfection is attained not when there is nothing more to add, but when there is nothing more to remove."

Antoine de Saint Exupéry

PS: And I think that Laurent is French.  :)

Title: Re: addColor method
Post by: korczurekk on August 31, 2017, 07:16:50 pm
Yep, there's no need for move tbh. I rarely used it in bigger projects.
It would be nice however, if sf::Sprite still did provide it. That's quite an important method for beginners, even though that's not a reason for it to be in sf::Transformable.