Page 1 of 2

cindy - [0-255] color range in LÖVE 11

Posted: Mon Apr 23, 2018 7:34 am
by grump
cindy is a small library that adds several functions to LÖVE 11 that allow you to work with a [0-255] color value range instead of the newly introduced [0.0-1.0] range in love.graphics, ImageData, ParticleSystem, SpriteBatch, and Shader.

Besides adding new functions, it also provides a mechanism to patch all relevant functions and restore the 0.10 behavior. This makes it easy to port your existing projects without having to change a lot of code.

GitHub repo with code and documentation.
License: WTFPL

Thanks to ivan and pgimeno for doing code reviews and providing valuable input!

Re: cindy - [0-255] color range in LÖVE 11

Posted: Mon Apr 23, 2018 2:53 pm
by ivan
Great job with this lib, looks much cleaner!

Re: cindy - [0-255] color range in LÖVE 11

Posted: Sun Nov 05, 2023 3:10 pm
by farvardin
it's working fine. IMHO it wasn't a good idea to make this breaking change, especially when most color pickers are using a 0-255 range for colors, it's a real PITA to work with colors since Löve 11. It don't understand the benefit of this.

Re: cindy - [0-255] color range in LÖVE 11

Posted: Sun Nov 05, 2023 3:17 pm
by BrotSagtMist
The benefit is that you are not restricted to 8bit values.

Re: cindy - [0-255] color range in LÖVE 11

Posted: Sun Nov 05, 2023 3:54 pm
by farvardin
BrotSagtMist wrote: Sun Nov 05, 2023 3:17 pm The benefit is that you are not restricted to 8bit values.
maybe some gradients could benefit from this then... even if I suppose many monitors won't support this yet.

Anyway, I've found this tool coded in Löve very convenient to pick a color: viewtopic.php?p=257037#p257037

Re: cindy - [0-255] color range in LÖVE 11

Posted: Sun Nov 05, 2023 7:15 pm
by dusoft
farvardin wrote: Sun Nov 05, 2023 3:10 pm it's working fine. IMHO it wasn't a good idea to make this breaking change, especially when most color pickers are using a 0-255 range for colors, it's a real PITA to work with colors since Löve 11. It don't understand the benefit of this.
You just have to use one more function:
https://love2d.org/wiki/love.math.colorFromBytes

I also originally thought it wasn't a good idea (=breaking change), check my old rant:
https://ambience.sk/on-backward-compatibility/

But adding one more function to work with 255 ranges is alright with me these days.

Re: cindy - [0-255] color range in LÖVE 11

Posted: Sun Nov 05, 2023 8:53 pm
by farvardin
thank you @dusoft for pointing me toward this colorFromBytes function!
Sure it's not easy to find a good balance between breaking everything to move forward, and keeping old, dormant, deprecated code for compatibility's sake...

Re: cindy - [0-255] color range in LÖVE 11

Posted: Wed Nov 08, 2023 9:31 am
by togFox
Am I doing something wrong by taking the colour code and dividing by 255?

Re: cindy - [0-255] color range in LÖVE 11

Posted: Wed Nov 08, 2023 1:37 pm
by milon
togFox wrote: Wed Nov 08, 2023 9:31 am Am I doing something wrong by taking the colour code and dividing by 255?
Nope. That's exactly how to convert a 0..255 range to a 0..1 range. (No, I don't understand the agita here either.)

Re: cindy - [0-255] color range in LÖVE 11

Posted: Tue Nov 14, 2023 3:42 pm
by BrotSagtMist
Gosh again, not every pixel has a range of 255.
But more importantly using percentages is great.
Yall should get your head checked for wanting integers.