crystal.Color

A color, with RGBA components.

Color components are stored in the array part of these objects. This makes them compatible with LOVE functions that expect colors as {r, g, b} or {r, g, b, a} tables.

Constructor

crystal.Color:new(hex_rgb, alpha)
  • The hex_rgb parameter is a number (not a string!) listing the RGB components of the color (8 bits per channel). If nil or omitted, it defaults to 0x000000 (black).
  • The alpha parameter is a number between 0 and 1 indicating the color opacity. If nil or omitted, it defaults to 1 (fully opaque).
local black_opaque  = crystal.Color:new();
local pink_opaque  = crystal.Color:new(0xFFC0CB, 1);
local turquoise_transparent  = crystal.Color:new(0x30D5C8, 0.5);

Methods

Name Description
alpha Creates a new color with the same RGB components and a specific alpha.

Constants

Debug Palette

These colors are used by Crystal to draw debug information on top of the game, such as collision shapes or navigation polygons.

Name Value
crystal.Color.sunflower 0xFFC312
crystal.Color.radiant_yellow 0xF79F1F
crystal.Color.puffins_bill 0xEE5A24
crystal.Color.red_pigment 0xEA2027
crystal.Color.energos 0xC4E538
crystal.Color.android_green 0xA3CB38
crystal.Color.pixelated_grass 0x009432
crystal.Color.turkish_aqua 0x006266
crystal.Color.blue_martina 0x12CBC4
crystal.Color.mediterranean_sea 0x1289A7
crystal.Color.merchant_marine_blue 0x0652DD
crystal.Color.leagues_under_the_sea 0x1B1464
crystal.Color.lavender_rose 0xFDA7DF
crystal.Color.lavender_tea 0xD980FA
crystal.Color.forgotten_purple 0x9980FA
crystal.Color.circumorbital_ring 0x5758BB
crystal.Color.bara_red 0xED4C67
crystal.Color.very_berry 0xB53471
crystal.Color.hollyhock 0x833471
crystal.Color.magenta_purple 0x6F1E51

Tools Palette

Unstable

These colors are used by crystal to draw interactive tools like the console.

Name Value
crystal.Color.black 0x000000
crystal.Color.white 0xFFFFFF
crystal.Color.red 0xFF5733
crystal.Color.green 0x84D728
crystal.Color.cyan 0x00B3CC
crystal.Color.grey0 0x11121D
crystal.Color.greyA 0x1A1B2B
crystal.Color.greyB 0x22263D
crystal.Color.greyC 0x373C53
crystal.Color.greyD 0xB0BED5

Examples

local orange = crystal.Color:new(0xFFA500);
love.graphics.setColor(orange);
love.graphics.rectangle("fill", 20, 50, 60, 120);
love.graphics.setColor(crystal.Color.energos);
love.graphics.rectangle("fill", 20, 50, 60, 120);

This site uses Just the Docs, a documentation theme for Jekyll.