One file simple color manipulation library. Used for color conversion and math.
All functions can take an alpha
after the three components of a color. This variable is not modified, but passed through for convenience. Whenever you pass a color, you can either pass a table or an unpacked list of arguments.
Included in this repository is a simple example using Quickie that demonstrates the uses of this library. It can also serve as a tool if you need a good color picking utility for when you use this library. If it has problems finding vivid you will either need to make a symlink or just copy the file over.
All conversion formulas are taken from EasyRGB with the exception of HuSL (which is not included yet).
This library works in the following colorspaces:
Lab
in the code)LCH
in the code)Luv
in the code)And hopefully soon:
colorspace
(r,g,b,a)Returns the four components of colorspace
.
print(vivid.RGBtoHSL(10,20,10,100))
colorspace
toRGB(h,s,l,alpha)Return r
,g
,b
,a
components of the colorspace
input.
print(vivid.HSVtoRGB(0,1,0.5))
Most of these manipulations take color
which looks like {r,g,b,a}
or just four more arguments r,g,b,a
, performs the operation, and returns the modified color. Color spaces used are chosen due to my somewhat limited understanding on how each performs.
Uses the HSL colorspace.
Uses the HSL colorspace.
Uses the HSV colorspace.
Uses the HSV colorspace.
Sets the hue using HSL.
Inverts the color using simple RGB inversion.
Inverts the color using simple 1-hue
inversion in HSL.
These functions return an even spread of colors across a color space. It will take evenly spaced h values across the whole colorspace and use the other given values for colors. Useful for quick and easy color scheme generation for random colors and such. count
is how many colors you want, and hoffset
is the hue offset.
colorspace
(fn)Wraps fn that may normally take RGBA arguments to take colorspace
argument.
Author: WetDesertRock
Source Code: https://github.com/WetDesertRock/vivid
License: MIT license