Monocurl
Download

std.color

color.mcl

Reference for the symbols exported by color.mcl.

Index

Declarations

Declarations

importantfunction

Build an RGBA color from HSV components.

Hue wraps modulo 1, so hsv(1.1, s, v) is the same hue as hsv(0.1, s, v).

let hsv = |h, s, v, a = 1| ...
hhue wrapped over [0, 1]
ssaturation in [0, 1]
vvalue in [0, 1]
aalpha component in [0, 1], default 1
let palette = [hsv(0.55, 0.7, 0.9), hsv(0.85, 0.5, 0.9)]
importantoperator

Return a color with the same RGB channels and a new alpha component.

This is an operator so it composes naturally inside styling, for example fill{alpha{0.16} BLUE}.

let alpha = operator |target, a| ...
imagedoc-color-alpha-1.mcl
rendered monocurl scene
mesh disk = fill{alpha{0.16} BLUE} Circle(1)
constant

Warm red RGBA color constant.

let RED = [0.9, 0.3, 0.2, 1]
imagedoc-color-red-1.mcl
rendered monocurl scene
mesh dot = fill{RED} Circle(0.4)
constant

Warm orange RGBA color constant.

let ORANGE = [1.0, 0.7, 0.2, 1]
constant

Bright yellow RGBA color constant.

let YELLOW = [1.0, 1.0, 0.0, 1]
constant

Green RGBA color constant.

let GREEN = [0.2, 0.6, 0.3, 1]
constant

Teal RGBA color constant.

let TEAL = [0.2, 0.7, 0.7, 1]
constant

Cyan RGBA color constant.

let CYAN = [0.1, 0.7, 0.9, 1]
constant

Blue RGBA color constant.

let BLUE = [0.1, 0.4, 0.6, 1]
constant

Dark blue RGBA color constant.

let NAVY = [0.05, 0.1, 0.4, 1]
constant

Purple RGBA color constant.

let PURPLE = [0.6, 0.4, 0.7, 1]
constant

Magenta RGBA color constant.

let MAGENTA = [0.9, 0.2, 0.7, 1]
constant

Pink RGBA color constant.

let PINK = [1.0, 0.6, 0.7, 1]
constant

Brown RGBA color constant.

let BROWN = [0.5, 0.3, 0.2, 1]
constant

White RGBA color constant.

let WHITE = [1.0, 1.0, 1.0, 1]
constant

Light gray RGBA color constant.

let LIGHT_GRAY = [0.7, 0.7, 0.7, 1]
constant

Middle gray RGBA color constant.

let GRAY = [0.5, 0.5, 0.5, 1]
constant

Dark gray RGBA color constant.

let DARK_GRAY = [0.3, 0.3, 0.3, 1]
constant

Black RGBA color constant.

let BLACK = [0.0, 0.0, 0.0, 1]
constant

Fully transparent black, useful for invisible fills and empty strokes.

let CLEAR = [0.0, 0.0, 0.0, 0]
imagedoc-color-clear-1.mcl
rendered monocurl scene
mesh ring = fill{CLEAR} stroke{CYAN} Circle(1)
function

Build an RGBA color from red, green, blue, and optional alpha components.

let rgb = |r, g, b, a = 1| [r, g, b, a]
rred component in [0, 1]
ggreen component in [0, 1]
bblue component in [0, 1]
aalpha component in [0, 1], default 1
mesh item = fill{rgb(0.2, 0.7, 0.9, 0.25)} Circle(1)
function

Build a gray RGBA color from one luminance value and optional alpha.

let gray_shade = |v, a = 1| [v, v, v, a]
vgray value in [0, 1]
aalpha component in [0, 1], default 1
mesh label = color{gray_shade(0.25)} Text("dim")