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

Showcase your libraries, tools and other projects that help your fellow love users.
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

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

Post 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!
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

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

Post by ivan »

Great job with this lib, looks much cleaner!
User avatar
farvardin
Party member
Posts: 167
Joined: Sat Jun 28, 2008 6:46 pm

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

Post 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.
User avatar
BrotSagtMist
Party member
Posts: 659
Joined: Fri Aug 06, 2021 10:30 pm

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

Post by BrotSagtMist »

The benefit is that you are not restricted to 8bit values.
obey
User avatar
farvardin
Party member
Posts: 167
Joined: Sat Jun 28, 2008 6:46 pm

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

Post 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
User avatar
dusoft
Party member
Posts: 654
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

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

Post 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.
User avatar
farvardin
Party member
Posts: 167
Joined: Sat Jun 28, 2008 6:46 pm

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

Post 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...
User avatar
togFox
Party member
Posts: 828
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

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

Post by togFox »

Am I doing something wrong by taking the colour code and dividing by 255?
Last edited by togFox on Wed Nov 08, 2023 9:25 pm, edited 1 time in total.
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/idle-gridiron
User avatar
milon
Party member
Posts: 472
Joined: Thu Jan 18, 2018 9:14 pm

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

Post 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.)
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
User avatar
BrotSagtMist
Party member
Posts: 659
Joined: Fri Aug 06, 2021 10:30 pm

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

Post 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.
obey
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests