Library to modify, transform and convert colors. To use defined named colors and paletts, generate random colors and get a random palett.
Screenshot from the example/test scene.
To use the library in a Defold project this project has to be added as a Defold library dependency. Open the game.project file and in the Dependencies field in the Project section add:
https://github.com/Jerakin/defold-color/archive/master.zip
Or point to the ZIP file of a specific release.
Convert colors between rgb, hsv, and hex
Converts a hex string into a color vector.
PARAMETERS
• str (string) - The color in a hex format, accepts it with and without th #.
It also the supports the shorthand for hex colors.
RETURN
• color (vmath.vector4)
Converts a color vector into a hex string.
PARAMETERS
• color (vmath.vector4) - The color in a vmath.vector4 format, alpha is discarded.
RETURN
• string (string) - The hex string.
Converts a table of values into a color vector. There is also a
color.from_table_255 that assumes values in a 0-255 format.
PARAMETERS
• tbl (table) - The color in a {1.0, 1.0, 1.0, 1.0} format (alpha optional, defaults to 1).
RETURN
• color (vmath.vector4)
Transforms the color into a table. There is also a color.to_table_255 that converts
the values into 0-255 values.
PARAMETERS
• color (vmath.vector4)
RETURN
• table (table) - The color as a table.
Converts the arguments into a color vector. There is also a color.from_rgba_255 that assumes
values in a 0-255 format.
PARAMETERS
• r (number) - The red component of the color
• g (number) - The green component of the color
• b (number) - The blue component of the color
• a (number) - Optional alpha component of the color ( defualts to 1)
RETURN
• color (vmath.vector4)
Converts h, s, v values into color vector.
PARAMETERS
• hue (number) - The hue component of the color
• saturation (number) - The saturation component of the color
• value (number) - The value component of the color
RETURN
• color (vmath.vector4)
Converts the color to a table of HSV values.
PARAMETERS
• color (vmath.vector4)
RETURN
• hue (number) - The hue component of the color
• saturation (number) - The saturation component of the color
• value (number) - The value component of the color
Shift the color along the color wheel.
PARAMETERS
• color (vmath.vector4) The starting color to shift.
• value (number) Percental shift (0-1) around the wheel, defaults to a random value of 1 to 2 percent.
RETURN
• color (vmath.vector4)
Perform arithmetic and blend modes.
Looks at the color information in each channel and subtracts the blend color from the base color.
PARAMETERS
• base (vmath.vector4) - The base color
• blend (vmath.vector4) - The color that will be used for the blending
RETURN
• color (vmath.vector4)
Looks at each channel’s color information and multiplies the inverse of the blend and base colors
PARAMETERS
• base (vmath.vector4) - The base color
• blend (vmath.vector4) - The color that will be used for the blending
RETURN
• color (vmath.vector4)
Multiplies or screens the colors, depending on the base color.
PARAMETERS
• base (vmath.vector4) - The base color
• blend (vmath.vector4) - The color that will be used for the blending
RETURN
• color (vmath.vector4)
Inverts the color.
PARAMETERS
• color (vmath.vector4)
RETURN
• color (vmath.vector4)
Looks at the color information in each channel and multiplies the base color by the blend color.
PARAMETERS
• base (vmath.vector4) - The base color
• blend (vmath.vector4) - The color that will be used for the blending
RETURN
• color (vmath.vector4)
Looks at the color information in each channel and adds the blend color to the base color.
PARAMETERS
• base (vmath.vector4) - The base color
• blend (vmath.vector4) - The color that will be used for the blending
RETURN
• color (vmath.vector4)
Looks at the color information in each channel and divides the base color with blend color.
PARAMETERS
• base (vmath.vector4) - The base color
• blend (vmath.vector4) - The color that will be used for the blending
RETURN
• color (vmath.vector4)
Looks at the color information in each channel and subtracts the blend color to the base color.
PARAMETERS
• base (vmath.vector4) - The base color
• blend (vmath.vector4) - The color that will be used for the blending
RETURN
• color (vmath.vector4)
Brighter than the Screen blend mode. Results in an intense,
contrasty color-typically results in saturated mid-tones and blown highlights.
PARAMETERS
• base (vmath.vector4) - The base color
• blend (vmath.vector4) - The color that will be used for the blending
RETURN
• color (vmath.vector4)
Darker than Multiply, with more highly saturated mid-tones and reduced highlights.
PARAMETERS
• base (vmath.vector4) - The base color
• blend (vmath.vector4) - The color that will be used for the blending
RETURN
• color (vmath.vector4)
Brighter than the Color Dodge blend mode, but less saturated and intense. (Same as cmath.add)
PARAMETERS
• base (vmath.vector4) - The base color
• blend (vmath.vector4) - The color that will be used for the blending
RETURN
• color (vmath.vector4)
Darker than Multiply, with more highly saturated mid-tones and reduced highlights.
PARAMETERS
• base (vmath.vector4) - The base color
• blend (vmath.vector4) - The color that will be used for the blending
RETURN
• color (vmath.vector4)
Create complementary colors from your base color.
The complementary color is the color on the opposite side of the color wheel.
PARAMETERS
• start_color (vmath.vector4) - The color to generate from.
RETURN
• color (vmath.vector4)
Generate an Array of colors that are all the varieties of a single hue the
tints, shades, and tones.
PARAMETERS
• start_color (vmath.vector4) - The color to generate from.
RETURN
• array (vmath.vector4) - Array of Vector4 colors of length count
An analogous color scheme involves three hues, all of which are positioned next
to each other on the color wheel.
PARAMETERS
• start_color (vmath.vector4) - The color to generate from.
RETURN
• array (vmath.vector4) - The two colors that are analogous to the input.
Generate the two colors lying on either side of the start_color
(the complementary) color.
PARAMETERS
• start_color (vmath.vector4) - The color to generate from.
RETURN
• array (vmath.vector4) - Array of the two complementary colors.
Generate the two colors that are triadic color.
Triadic colors are equidistant on the color wheel.
PARAMETERS
• start_color (vmath.vector4) - The color to generate from.
RETURN
• array (vmath.vector4) - Array of the two colors to complement
the start_color to make a triadic color scheme.
A tetrad is four colors, that is, two pairs of complementary combinations.
PARAMETERS
• start_color (vmath.vector4) - The color to generate from.
RETURN
• colors (table) - Array of the three colors to complement the
starting color to make a tetradic color scheme.
Contains a few palettes (with made up named), they are between 5 and 10 colors.
Returns a random palett
PARAMETERS
• None
RETURN
• colors (table) - Table containing (vmath.vector4) colors of the palett.
• name (string) - Name of the generated palette.
Returns a random palett
PARAMETERS
• name (string) - Name of the generated palette.
• palette (table) - Table containing (vmath.vector4) colors of the palett.
RETURN
• None