loveCC: ColorCodes library for Love2D

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
YoungNeer
Party member
Posts: 118
Joined: Wed May 15, 2019 7:49 am

loveCC: ColorCodes library for Love2D

Post by YoungNeer »

loveCC is a helper library for LOVE2D to help you with colors in general.
The library is available at github, make your contributions (anyone can contribute)
https://github.com/YoungNeer/lovelib/tree/master/lovecc
To use loveCC you simply have to require it like this-

Code: Select all

	lovecc=require 'lovecc'
Let's say you want to print red text on the screen, how would you do that?

Code: Select all

	love.graphics.setColor(1,0,0)
Right?
But the way you'd do the same using lovecc is-

Code: Select all

	lovecc:setColor('red')
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:

Code: Select all

	love.graphics.setColor(lovecc:getHex('ffd700'))
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,

Code: Select all

	lovecc:setOpacity(a)
In general you could set colors like this:-

Code: Select all

	lovecc:setColor(colorname,opacity)
	lovecc:setBackgroundColor(colorname,opacity)
	lovecc:setParticleColors(particle,...)
And of-course you could add your own colors very easily which makes it very flexible:-

Code: Select all

	lovecc:newColor(colorname,r,g,b)
	lovecc:newColor(colorname,hex)
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:-

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)
So if the current color is black and you used invert() then you will get white color!!
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 ().
Last edited by YoungNeer on Sun Jul 28, 2019 11:57 am, edited 2 times in total.
My Github- your contribution is highly appreciated
User avatar
yetneverdone
Party member
Posts: 446
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: loveCC: ColorCodes library for Love2D

Post by yetneverdone »

How are you making many libraries in a small amount of time.

Anyways, I'll take a look at this one
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: loveCC: ColorCodes library for Love2D

Post by raidho36 »

You just write. This stuff is pretty trivial to implement.
User avatar
YoungNeer
Party member
Posts: 118
Joined: Wed May 15, 2019 7:49 am

Re: loveCC: ColorCodes library for Love2D

Post by YoungNeer »

raidho36 wrote: Mon Jul 22, 2019 10:36 am You just write. This stuff is pretty trivial to implement.
Trivial yet useful!! :nyu:
My Github- your contribution is highly appreciated
User avatar
YoungNeer
Party member
Posts: 118
Joined: Wed May 15, 2019 7:49 am

Re: loveCC: ColorCodes library for Love2D

Post by YoungNeer »

yetneverdone wrote: Mon Jul 22, 2019 9:47 am How are you making many libraries in a small amount of time.
Anyways, I'll take a look at this one
I'd be happy if you do look and since it's so trivial I didn't waste time on making demos (like I do with other libraries). And regarding how I make so many libraries in a small amount of time - well as raidho36 pointed out I don't make very complicated stuff (the only complicated Library I ever wrote is Anima (https://love2d.org/forums/viewtopic.php?f=5&t=86885) - which is internally so complicated that I've quit working on that and even though it's undocumented it has good no of examples to get one started).

loveCC is one of those libraries which you can use in all of your projects. And it's also one of those libraries to which ANYONE CAN CONTRIBUTE. Either to contribute to the main library or you can contribute to the default color-palette. Just wikipedia important colors such as 'leafgreen',etc and add the hex code (or rgb triplet) to the database which is very easy to do.

Anyways thanks for showing interest on a no-one's library
My Github- your contribution is highly appreciated
User avatar
CrimsonGuy
Prole
Posts: 48
Joined: Thu Apr 04, 2019 3:32 pm

Re: loveCC: ColorCodes library for Love2D

Post by CrimsonGuy »

The allcolors.lua file can be very useful, just wish it was in the love format of (1,0,0), but still good and today i learned that there's a color that has the same name as my country ^^
User avatar
YoungNeer
Party member
Posts: 118
Joined: Wed May 15, 2019 7:49 am

Re: loveCC: ColorCodes library for Love2D

Post by YoungNeer »

CrimsonGuy wrote: Mon Jul 29, 2019 4:04 am The allcolors.lua file can be very useful, just wish it was in the love format of (1,0,0), but still good
Well you could easily convert them into love format (and even the generic 8 byte rgb triplet format). For reference see viewtopic.php?f=5&t=86958.
CrimsonGuy wrote: Mon Jul 29, 2019 4:04 am today i learned that there's a color that has the same name as my country ^^
You mean peru?
My Github- your contribution is highly appreciated
User avatar
D0NM
Party member
Posts: 250
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

Re: loveCC: ColorCodes library for Love2D

Post by D0NM »

I had to invent a wheel )))
But it looks pretty the same as yours.
Our LÖVE Gamedev blog Zabuyaki (an open source retro beat 'em up game). Twitter: @Zabuyaki.
:joker: LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua :joker:
User avatar
YoungNeer
Party member
Posts: 118
Joined: Wed May 15, 2019 7:49 am

Re: loveCC: ColorCodes library for Love2D

Post by YoungNeer »

D0NM wrote: Mon Jul 29, 2019 10:54 am I had to invent a wheel )))
But it looks pretty the same as yours.
Yeah I know. Infact I believe every Love2D out there has it's counterpart somewhere buried in some part of github space. But that being said no two counter-parts are exactly the same (unless it was intentional). There is always some difference - either in the implementation or syntax
My Github- your contribution is highly appreciated
Post Reply

Who is online

Users browsing this forum: No registered users and 60 guests