Page 4 of 4

Re: What was the reasoning for changing setColor from RGB 0-255 to 0-1 interval?

Posted: Mon Oct 22, 2018 9:37 pm
by slime
It's not an implementation detail, it's consistency and extensibility. Previous love versions already had colors in the 0-1 range... but only in shaders, which is not consistent. love 11 also allows you to create and modify ImageData at different bit depths than 8 bits per color component (e.g. via ImageData:setPixel), whereas 0-255 only makes sense for 8 bits. Math on colors (such as interpolation, etc) is generally simplified when working in the 0-1 range as well.

0-255 (or hex) colors do make sense for certain scenarios, but they are not universally applicable, they have a narrower range of use than love's APIs, whereas 0-1 colors (or unbounded range colors in some scenarios) allow for a variety of inputs and outputs. Adding a simple function to convert 0-255 to 0-1 (and potentially other color conversion functions, although there are a lot of color spaces and few are really useful for games) might be helpful, but having love's base APIs take 0-1 colors was a necessary change.

Certain other engines have explicit float-color and byte-color objects, and have implicit conversions from byte-color to float-color objects. Unfortunately that's not feasible in Lua since the language doesn't have stack allocated value-type structures (tables would be far too expensive in terms of GC pressure).

Re: What was the reasoning for changing setColor from RGB 0-255 to 0-1 interval?

Posted: Wed Oct 24, 2018 10:30 pm
by dusoft
slime wrote: Mon Oct 22, 2018 9:37 pm Adding a simple function to convert 0-255 to 0-1 (and potentially other color conversion functions, although there are a lot of color spaces and few are really useful for games) might be helpful, but having love's base APIs take 0-1 colors was a necessary change.
I understand the goal was to standardize. Maybe, it would be the right thing to add a conversion function (helper) for people using 0-255. (I know it's easy to code this, but that's one more reason this could have gotten into Love codebase).

Thanks for joining the discussion.

Re: What was the reasoning for changing setColor from RGB 0-255 to 0-1 interval?

Posted: Thu Oct 25, 2018 6:32 am
by grump
dusoft wrote: Wed Oct 24, 2018 10:30 pm Maybe, it would be the right thing to add a conversion function (helper) for people using 0-255.
I made this. It patches all relevant functions for you when you start your game and forces everything (not just the trivial functions) back to 0-255 in a transparent way, as if the change never happened.

Re: What was the reasoning for changing setColor from RGB 0-255 to 0-1 interval?

Posted: Thu Oct 25, 2018 5:51 pm
by dusoft
grump wrote: Thu Oct 25, 2018 6:32 am
dusoft wrote: Wed Oct 24, 2018 10:30 pm Maybe, it would be the right thing to add a conversion function (helper) for people using 0-255.
I made this. It patches all relevant functions for you when you start your game and forces everything (not just the trivial functions) back to 0-255 in a transparent way, as if the change never happened.
Great, will check that!

Re: What was the reasoning for changing setColor from RGB 0-255 to 0-1 interval?

Posted: Thu Nov 01, 2018 5:16 pm
by dusoft
BTW, found this game which I believe has been written by slime:
https://github.com/wesleywerner/nova-pi ... tag/v0.2.3

Unable to run as it only supports 10.x and crashes.

Re: What was the reasoning for changing setColor from RGB 0-255 to 0-1 interval?

Posted: Thu Nov 01, 2018 6:44 pm
by grump
dusoft wrote: Thu Nov 01, 2018 5:16 pm BTW, found this game which I believe has been written by slime:
https://github.com/wesleywerner/nova-pi ... tag/v0.2.3

Unable to run as it only supports 10.x and crashes.
Runs fine with polyamory on Debian Stretch.

Thread's gone seriously off topic.

Re: What was the reasoning for changing setColor from RGB 0-255 to 0-1 interval?

Posted: Thu Nov 01, 2018 7:32 pm
by pgimeno
I guess dusoft's point is about cross-version compatibility, which is kinda on-topic. Yeah, there are lot more programs that break from one version to another. When a new version appears, I update my programs to adapt them to run in all versions, because they generally don't (T2R is already updated, but not pushed yet), but not everyone does the same.

On a side note, what makes you think Wesley Werner is Alex Szpakowski?

Re: What was the reasoning for changing setColor from RGB 0-255 to 0-1 interval?

Posted: Sat Nov 03, 2018 9:59 pm
by dusoft
pgimeno wrote: Thu Nov 01, 2018 7:32 pm On a side note, what makes you think Wesley Werner is Alex Szpakowski?
Ah, It was just a guess based on this: https://github.com/wesleywerner/loveslime

Re: What was the reasoning for changing setColor from RGB 0-255 to 0-1 interval?

Posted: Tue Nov 06, 2018 1:32 pm
by deströyer
A suggestion which has worked for me: 97% of my game is in pure lua, it never calls the Love API. Everything goes through a 'framework'-module that handles the actual API calls to things like reading/writing data, controller input, drawing stuff, etc. So when eg. love.graphics.drawq was removed I only needed to change ONE line of code! :3

Re: What was the reasoning for changing setColor from RGB 0-255 to 0-1 interval?

Posted: Thu Nov 08, 2018 11:24 pm
by dusoft
So you built another framework :-) Or a connector. Or a bridge. Erm, smart, but thanks no thanks.