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

// Use predefined colors
var red = Color.RED;
var blue = Color.BLUE;

// Create from hex value
var purple = 0x9400D3;

// Create from RGB values
var orange = Color.fromRGB(255, 165, 0);

// Create from HSB (hue, saturation, brightness)
var cyan = Color.fromHSB(180, 1.0, 1.0);

// Interpolate between colors
var blend = Color.interpolate(red, blue, 0.5);

// Modify colors
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
















random(?minSatutation: Float = 0.5, ?minBrightness: Float = 0.5): ceramic.Color

Generate a random color (away from white or black)

Name Type Default
minSatutation Float 0.5
minBrightness Float 0.5
Returns Description
ceramic.Color The color as a Color

fromInt(value: Int): ceramic.Color

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
Returns Description
ceramic.Color The color as a Color

fromRGB(red: Int, green: Int, blue: Int): ceramic.Color

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
Returns Description
ceramic.Color The color as a Color

fromRGBFloat(red: Float, green: Float, blue: Float): ceramic.Color

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
Returns Description
ceramic.Color The color as a Color

fromCMYK(cyan: Float, magenta: Float, yellow: Float, black: Float): ceramic.Color

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
Returns Description
ceramic.Color The color as a Color

fromHSB(hue: Float, saturation: Float, brightness: Float): ceramic.Color

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.
Returns Description
ceramic.Color The color as a Color

fromHSL(hue: Float, saturation: Float, lightness: Float): ceramic.Color

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
Returns Description
ceramic.Color The color as a Color

fromString(str: String): Null<ceramic.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

getHSBColorWheel(): Array<ceramic.Color>

Get HSB color wheel values in an array which will be 360 elements in size

Returns Description
Array<ceramic.Color> HSB color wheel as Array of Colors

interpolate(color1: ceramic.Color, color2: ceramic.Color, ?factor: Float = 0.5): ceramic.Color

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
Returns Description
ceramic.Color The interpolated color

gradient(color1: ceramic.Color, color2: ceramic.Color, steps: Int, ?ease: Function): Array<ceramic.Color>

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

Name Type
lhs ceramic.Color
rhs ceramic.Color
Returns
ceramic.Color

Add the RGB channels of two Colors

Name Type
lhs ceramic.Color
rhs ceramic.Color
Returns
ceramic.Color

Subtract the RGB channels of one Color from another

Name Type
lhs ceramic.Color
rhs ceramic.Color
Returns
ceramic.Color

toHexString(color: ceramic.Color, ?prefix: Bool = true): String

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

toWebString(color: ceramic.Color): String

Return a String representation of the color in the format #RRGGBB

Name Type
color ceramic.Color
Returns Description
String A string of length 7 in the format #RRGGBB

getColorInfo(color: ceramic.Color): String

Get a string of color information about this color

Name Type
color ceramic.Color
Returns Description
String A string containing information about this color

getDarkened(color: ceramic.Color, ?factor: Float = 0.2): ceramic.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

getLightened(color: ceramic.Color, ?factor: Float = 0.2): ceramic.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

getInverted(color: ceramic.Color): ceramic.Color

Get the inversion of this color

Name Type
color ceramic.Color
Returns Description
ceramic.Color The inversion of this color

hue(color: ceramic.Color): Float

Get the hue of the color in degrees (from 0 to 359)

Name Type
color ceramic.Color
Returns
Float

saturation(color: ceramic.Color): Float

Get the saturation of the color (from 0 to 1)

Name Type
color ceramic.Color
Returns
Float

brightness(color: ceramic.Color): Float

Get the brightness (aka value) of the color (from 0 to 1)

Name Type
color ceramic.Color
Returns
Float

lightness(color: ceramic.Color): Float

Get the lightness of the color (from 0 to 1)

Name Type
color ceramic.Color
Returns
Float

red(color: ceramic.Color): Int
Name Type
color ceramic.Color
Returns
Int

green(color: ceramic.Color): Int
Name Type
color ceramic.Color
Returns
Int

blue(color: ceramic.Color): Int
Name Type
color ceramic.Color
Returns
Int

redFloat(color: ceramic.Color): Float
Name Type
color ceramic.Color
Returns
Float

greenFloat(color: ceramic.Color): Float
Name Type
color ceramic.Color
Returns
Float

blueFloat(color: ceramic.Color): Float
Name Type
color ceramic.Color
Returns
Float

fromHSLuv(hue: Float, saturation: Float, lightness: Float): ceramic.Color

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
Returns Description
ceramic.Color The color as a Color

getHSLuv(color: ceramic.Color, ?result: Array<Float>): Array<Float>

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