For playing with colors.
local Color = require('__stdlib__/stdlib/utils/color')
color |
anticolor |
lightcolor |
new(any) | Create a new Color object. |
load(color) | Loads the color metatmethods into table without any checking. |
copy(color[, alpha]) | Copies the color into a new Color. |
white() | Returns a white Color. |
black() | Returns a black color. |
from_string(string_name[, alpha]) | Returns a color from a string name if known. |
from_params([r=0][, g=0][, b=0][, a=255]) | Converts a color in the rgb format to a color table. |
from_rgb | |
from_array(color[, alpha]) | Converts a color in the array format to a color in the table format. |
from_table(color[, alpha]) | Converts a color in the dictionary format to a color in the Color format. |
from_hex(color[, alpha=1]) | Get a color table with a hexadecimal string. |
normalize(color) | Normalizes a color between 0 and 1 |
alpha(color, alpha) | Set the alpha channel on a color |
premul_alpha(color, alpha) | Premultiply alpha |
add(lhs, rhs) | Add 2 colors together. |
subtract(lhs, rhs) | Subtract 2 colors together. |
multiply(lhs, rhs) | Multiply 2 colors together. |
divide(lhs, rhs) | Add 2 colors together. |
modulo(lhs, rhs) | Modulo of 2 colors. |
unary(color) | Flip a color to white or black. |
len(color) | Get the length of a color by adding all its values together |
equals(lhs, rhs) | Are both colors equal. |
less_than(lhs, rhs) | Is LHS less than RHS. |
less_than_eq(lhs, rhs) | Is LHS less than or equal to RHS. |
to_hex(color) | Return a hex formated string from a color. |
to_array(color) | Return an array with 4 paramaters. |
pack | |
to_params(color) | Return the color as 4 paramaters. |
unpack | |
to_string(color) | Return the Color as a string. |
is_complex(color) | Is this a correctly formatted color. |
is_Color(color) | Is this a Color object. |
is_color(color) | Is this a Color object or correctly formatted color table. |
Create a new Color object.
it can be passed, A Color, a string color name, an array, a list of float paramaters (RGB), a color dictionary, or hex
Parameters:Loads the color metatmethods into table without any checking.
Parameters:
Copies the color into a new Color.
Parameters:
Returns a white Color.
Returns:
Returns a black color.
Returns:
Returns a color from a string name if known.
Returns white if color string is unknown
Parameters: Returns:Converts a color in the rgb format to a color table.
Parameters:
Converts a color in the array format to a color in the table format.
Parameters:
Converts a color in the dictionary format to a color in the Color format.
Parameters: Returns:
Get a color table with a hexadecimal string.
Optionally provide the value for the alpha channel.
Parameters:Normalizes a color between 0 and 1
Parameters:
Set the alpha channel on a color
Parameters:
Premultiply alpha
Parameters:
Add 2 colors together.
Parameters:
Subtract 2 colors together.
Parameters:
Multiply 2 colors together.
Parameters:
Add 2 colors together.
Parameters:
Modulo of 2 colors.
Parameters:
Flip a color to white or black.
Parameters:
Get the length of a color by adding all its values together
Parameters:
Are both colors equal.
Parameters:
Is LHS less than RHS.
Parameters:
Is LHS less than or equal to RHS.
Parameters:
Return a hex formated string from a color.
Parameters:
Return an array with 4 paramaters.
Parameters: