ScriptableColor
ceramic.scriptable.ScriptableColor (Class)
Scriptable wrapper for Color to expose RGB color functionality to scripts.
This class provides comprehensive color manipulation features for scripts.
In scripts, this type is exposed as Color
(without the Scriptable prefix)
and provides the same functionality as ceramic.Color.
Colors are represented as integers in RGB format (0xRRGGBB). You can use
hex values directly or create colors using various color space methods.
Usage in Scripts
var red = Color.RED;
var blue = Color.BLUE;
var purple = 0x9400D3;
var orange = Color.fromRGB(255, 165, 0);
var cyan = Color.fromHSB(180, 1.0, 1.0);
var blend = Color.interpolate(red, blue, 0.5);
var darkRed = Color.getDarkened(red, 0.3);
var lightBlue = Color.getLightened(blue, 0.3);
Color Spaces
- RGB: Red, Green, Blue (0-255 per channel)
- HSB/HSV: Hue (0-360°), Saturation (0-1), Brightness/Value (0-1)
- HSL: Hue (0-360°), Saturation (0-1), Lightness (0-1)
- CMYK: Cyan, Magenta, Yellow, Key/Black (0-1 per channel)
- HSLuv: Perceptually uniform color space (if enabled)
Note that colors are stored internally as RGB, so repeated conversions
between color spaces may result in precision loss.
See: ceramic.Color The actual implementation, ceramic.scriptable.ScriptableAlphaColor For colors with alpha channel
Static Members
Generate a random color (away from white or black)
Name |
Type |
Default |
minSatutation |
Float |
0.5 |
minBrightness |
Float |
0.5 |
Create a color from the least significant four bytes of an Int
Name |
Type |
Description |
value |
Int |
And Int with bytes in the format 0xRRGGBB |
Generate a color from integer RGB values (0 to 255)
Name |
Type |
Description |
red |
Int |
The red value of the color from 0 to 255 |
green |
Int |
The green value of the color from 0 to 255 |
blue |
Int |
The green value of the color from 0 to 255 |
Generate a color from float RGB values (0 to 1)
Name |
Type |
Description |
red |
Float |
The red value of the color from 0 to 1 |
green |
Float |
The green value of the color from 0 to 1 |
blue |
Float |
The green value of the color from 0 to 1 |
Generate a color from CMYK values (0 to 1)
Name |
Type |
Description |
cyan |
Float |
The cyan value of the color from 0 to 1 |
magenta |
Float |
The magenta value of the color from 0 to 1 |
yellow |
Float |
The yellow value of the color from 0 to 1 |
black |
Float |
The black value of the color from 0 to 1 |
Generate a color from HSB (aka HSV) components.
Name |
Type |
Description |
hue |
Float |
A number between 0 and 360, indicating position on a color strip or wheel. |
saturation |
Float |
A number between 0 and 1, indicating how colorful or gray the color should be. 0 is gray, 1 is vibrant. |
brightness |
Float |
(aka value) A number between 0 and 1, indicating how bright the color should be. 0 is black, 1 is full bright. |
Generate a color from HSL components.
Name |
Type |
Description |
hue |
Float |
A number between 0 and 360, indicating position on a color strip or wheel. |
saturation |
Float |
A number between 0 and 1, indicating how colorful or gray the color should be. 0 is gray, 1 is vibrant. |
lightness |
Float |
A number between 0 and 1, indicating the lightness of the color |
Parses a String
and returns a Color
or null
if the String
couldn't be parsed.
Examples (input -> output in hex):
0x00FF00
-> 0x00FF00
#0000FF
-> 0x0000FF
GRAY
-> 0x808080
blue
-> 0x0000FF
Name |
Type |
Description |
str |
String |
The string to be parsed |
Returns |
Description |
Null<ceramic.Color> |
A Color or null if the String couldn't be parsed |
Get HSB color wheel values in an array which will be 360 elements in size
Get an interpolated color based on two different colors.
Name |
Type |
Default |
Description |
color1 |
ceramic.Color |
|
The first color |
color2 |
ceramic.Color |
|
The second color |
factor |
Float |
0.5 |
value from 0 to 1 representing how much to shift color1 toward color2 |
Create a gradient from one color to another
Name |
Type |
Default |
Description |
color1 |
ceramic.Color |
|
The color to shift from |
color2 |
ceramic.Color |
|
The color to shift to |
steps |
Int |
|
How many colors the gradient should have |
ease |
Function |
(optional) |
An optional easing function, such as those provided in FlxEase |
Returns |
Description |
Array<ceramic.Color> |
An array of colors of length steps, shifting from color1 to color2 |
Multiply the RGB channels of two Colors
Add the RGB channels of two Colors
Subtract the RGB channels of one Color from another
Return a String representation of the color in the format
Name |
Type |
Default |
Description |
color |
ceramic.Color |
|
|
prefix |
Bool |
true |
Whether to include "0x" prefix at start of string |
Returns |
Description |
String |
A string of length 10 in the format 0xAARRGGBB |
Return a String representation of the color in the format #RRGGBB
Returns |
Description |
String |
A string of length 7 in the format #RRGGBB |
Get a string of color information about this color
Returns |
Description |
String |
A string containing information about this color |
Get a darkened version of this color
Name |
Type |
Default |
Description |
color |
ceramic.Color |
|
|
factor |
Float |
0.2 |
value from 0 to 1 of how much to progress toward black. |
Returns |
Description |
ceramic.Color |
A darkened version of this color |
Get a lightened version of this color
Name |
Type |
Default |
Description |
color |
ceramic.Color |
|
|
factor |
Float |
0.2 |
value from 0 to 1 of how much to progress toward white. |
Returns |
Description |
ceramic.Color |
A lightened version of this color |
Get the inversion of this color
Get the hue of the color in degrees (from 0 to 359)
Get the saturation of the color (from 0 to 1)
Get the brightness (aka value) of the color (from 0 to 1)
Get the lightness of the color (from 0 to 1)
Generate a color from HSLuv components.
Name |
Type |
Description |
hue |
Float |
A number between 0 and 360, indicating position on a color strip or wheel. |
saturation |
Float |
A number between 0 and 1, indicating how colorful or gray the color should be. 0 is gray, 1 is vibrant. |
lightness |
Float |
A number between 0 and 1, indicating the lightness of the color |
Get HSLuv components from the color instance.
Name |
Type |
Default |
Description |
color |
ceramic.Color |
|
|
result |
Array<Float> |
(optional) |
A pre-allocated array to store the result into. |
Returns |
Description |
Array<Float> |
The HSLuv components as a float array |