vivid.lua -- No longer crutch on RGB

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
WetDesertRock
Citizen
Posts: 67
Joined: Fri Mar 07, 2014 8:16 pm

vivid.lua -- No longer crutch on RGB

Post by WetDesertRock »

Just released my simple library for color conversion and manipulation. It is a step at relieving the crutch most developers (at least that I see) have on RGB. But before I say much more, have a picture of my example program:
Image

Github


While RGB is good and has its uses, it isn't very good at giving you a lot of control over colors. This is where vivid comes in, it gives you the chance to use 6 other color spaces instead of RGB. It provides functions to convert to and from these colorspaces, as well as wrapper functions to magically do it for you. For example, want to do love.graphics.setColor, but with HSL?

Code: Select all

setHSL = vivid.wrapHSL(love.graphics.setColor)
setHSL(0.3,0.5,0.5)
It also has simple color math to make your life easier. Want rgb(10,20,10), but lighter?

Code: Select all

r,g,b = vivid.lighten(0.1,10,20,10) -- Lightens by 0.1 using the HSL colorspace
It also introduces the ability to easily create color spreads. What about if you want 4 different random player colors?

Code: Select all

playerColors  = vivid.HSLSpread(4, math.random(), 0.3, 0.5) -- 4 colors, random hue offset, 0.3 saturation, 0.5 lightness
My curent plans for this library include making the internal mathy stuff use a more consistent style. I also plan on implementing some gamma correction and sRGB support, however I'm not familiar with that. Any pull requests, feature requests, or such are appreciated.
User avatar
BOT-Brad
Citizen
Posts: 87
Joined: Tue Dec 02, 2014 2:17 pm
Location: England

Re: vivid.lua -- No longer crutch on RGB

Post by BOT-Brad »

Very nice, thanks for posting this. Will make nice transitional colour tweens much easier with HSL rather than RGB which can be tricky at times.
Follow me on GitHub! | Send me a friend request on PSN!
User avatar
airstruck
Party member
Posts: 650
Joined: Thu Jun 04, 2015 7:11 pm
Location: Not being time thief.

Re: vivid.lua -- No longer crutch on RGB

Post by airstruck »

Interesting, I like it. Just some random thoughts:
  • Why are the lighten/darken/saturate/desaturate buttons necessary? Wouldn't adjusting the HSL sliders do the same thing?
  • Ten color swatches seems like a strange choice, aren't most (harmonic) color schemes based on a 12-hue color wheel?
  • Any plans to export palettes from color swatches? Personally I'd be interested in support for Inkscape, Gimp, and GrafX2 formats.
User avatar
qubodup
Inner party member
Posts: 775
Joined: Sat Jun 21, 2008 9:21 pm
Location: Berlin, Germany
Contact:

Re: vivid.lua -- No longer crutch on RGB

Post by qubodup »

lg.newImage("cat.png") -- made possible by lg = love.graphics
-- Don't force fullscreen (it frustrates those who want to try your game real quick) -- Develop for 1280x720 (so people can make HD videos)
WetDesertRock
Citizen
Posts: 67
Joined: Fri Mar 07, 2014 8:16 pm

Re: vivid.lua -- No longer crutch on RGB

Post by WetDesertRock »

time thief wrote:Interesting, I like it. Just some random thoughts:
  • Why are the lighten/darken/saturate/desaturate buttons necessary? Wouldn't adjusting the HSL sliders do the same thing?
  • Ten color swatches seems like a strange choice, aren't most (harmonic) color schemes based on a 12-hue color wheel?
  • Any plans to export palettes from color swatches? Personally I'd be interested in support for Inkscape, Gimp, and GrafX2 formats.
I'll go in order, but it all boils down to the example being a simple tool rather than a extensive program. The main feature is the library. All the example does is show what you can do with the library.
  • They aren't, but they show that the library can lighten and darken.
  • Random number, should I change it to 12? Ok, I'll change it to 12. Again, it just shows the vivid.HSL/HSV/LCHSpread functions.
  • I could, but its not made to be a fully featured palette creation tool. Maybe in the future I'll do research and make a library to make palettes. The most this library will ever do is calculate color harmonies.

Thanks for the video by the way. Not sure the random button is necessary. There are only three components to randomize. Its kinda like adding a random function to just a wave generator, it could only randomize the wave type, amplitude, and frequency.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: vivid.lua -- No longer crutch on RGB

Post by Positive07 »

Just one question that is decisive!
if I pass 1023 to R, G or B:
  • Does it clamp the numbers to a number between 0 and 255?
  • Does it make the function return weird results for the Hue Saturation and Value numbers?
When I pass 1.5 to the Hue:
  • Does it make 1?
  • Does it make it return weird numbers on my RGB values?
  • Does it wrap for example to 0.5 instead of clamping the value to 1?
  • Does the function error when the value is greater than 1or less than 0?
The library looks pretty neat and has more functionality than I could ask for! :awesome:

Would probably add (but maybe not as part of this lib, dont know) an hex string to RGB converter with the #FFF, #FFFFFF, #FFFF, #FFFFFF formats plus the same ones with "0x" instead of "#"
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
WetDesertRock
Citizen
Posts: 67
Joined: Fri Mar 07, 2014 8:16 pm

Re: vivid.lua -- No longer crutch on RGB

Post by WetDesertRock »

Good question, I will check, and then fix if it is wrong. I know that some weirdness may come with the CIE colorspaces. But honestly I don't know much about them.
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests