loveCC: ColorCodes library for Love2D
Posted: Mon Jul 22, 2019 6:14 am
loveCC is a helper library for LOVE2D to help you with colors in general.
Let's say you want to print red text on the screen, how would you do that?
Right?
But the way you'd do the same using lovecc is-
Okay that was not very interesting. Let's say we have a color whose hex is 'ffd700' then how would you set the color WITHOUT USING lovecc? --No replies--
So the way you would do that USING lovecc is:
Note: You could also use '#ffd700' instead of 'ffd700' - lovecc treats both as same
And if you want to change the opacity then you can use setOpacity function,
In general you could set colors like this:-
And of-course you could add your own colors very easily which makes it very flexible:-
And finally I'd like to talk about the default color-palette. So you don't have to redefine all the colors to use them. Common colors such as red,blue,crimson,maroon,lime,violet,purple,bla bla,bla have all been defined for you - Infact all the CSS Colors (except white) have been defined for you!!! And you just have to use them in setColor,etc functions.
Lastly let's talk about two new functions that has been added in the latest version of loveCC:-
So if the current color is black and you used invert() then you will get white color!!
To use loveCC you simply have to require it like this-The library is available at github, make your contributions (anyone can contribute)
https://github.com/YoungNeer/lovelib/tree/master/lovecc
Code: Select all
lovecc=require 'lovecc'
Code: Select all
love.graphics.setColor(1,0,0)
But the way you'd do the same using lovecc is-
Code: Select all
lovecc:setColor('red')
So the way you would do that USING lovecc is:
Code: Select all
love.graphics.setColor(lovecc:getHex('ffd700'))
And if you want to change the opacity then you can use setOpacity function,
Code: Select all
lovecc:setOpacity(a)
Code: Select all
lovecc:setColor(colorname,opacity)
lovecc:setBackgroundColor(colorname,opacity)
lovecc:setParticleColors(particle,...)
Code: Select all
lovecc:newColor(colorname,r,g,b)
lovecc:newColor(colorname,hex)
Lastly let's talk about two new functions that has been added in the latest version of loveCC:-
Code: Select all
lovecc:invert(colorname,opacity)
--inverts the given color and sets opacity to given value (or 1 if nil)
lovecc:invert(opacity)
--inverts the current color and sets opacity to given value (or 1 if nil)
Please check out the github link for the library with the FULL DOCUMENTATION
Also note that Color-Picker is not discussed in this topic! It is discussed here ().