Colours
Darker
darker · darker(color: colour, factor: double)
Darkens a colour by a factor, towards black. The result is a colour number; a style needs it as text: "#%06X".format(darker(rgb(1, 0, 0), 0.5)).
Parameters
| Name | Type | Description |
|---|---|---|
color |
colour |
The colour to darken. |
factor |
double |
How far to darken it, 0 leaving it unchanged and 1 reaching black. |
Returns colour: The darkened colour, as a colour number.
Examples
darker(rgb(1, 0.5, 0), 0.5) → 6307871
"#%06X".format(darker(rgb(1, 0.5, 0), 0.5)) → "#60401F"
Gradient
gradient · gradient(gradient_name: name, value: double)
Picks the colour a named gradient assigns to a value - the usual way to drive an indicator from a reading. The result is a colour number; a style needs it as text: "#%06X".format(gradient(rainbow, 0.5)).
Parameters
| Name | Type | Description |
|---|---|---|
gradient_name |
name |
The gradient's name, written bare rather than quoted - it is read as an identifier, not as text. A name the host has not registered is an error. |
value |
double |
The reading to look up along the gradient. |
Returns colour: The colour the gradient assigns to the value, as a colour number.
Examples
gradient(red2green, 0) → 16711680
"#%06X".format(gradient(red2green, 1)) → "#00FF00"
"#%06X".format(gradient(RED2GREEN, 0.5)) → "#FFFF00"
gradient(nosuch, 0.5) → error
HSL colour
hsl · hsl(h: double, s: double, l: double)
Builds a colour from hue, saturation and lightness - easier than RGB when a colour has to vary smoothly with a reading. The hue is in turns: 0 is red, 0.3333 green, 0.6667 blue. The result is a colour number; a style needs it as text: "#%06X".format(hsl(0.3333, 1, 0.5)).
Parameters
| Name | Type | Description |
|---|---|---|
h |
double |
The hue in turns, from 0 to 1; whole turns wrap round, so 1 is red again. |
s |
double |
The saturation, 0 to 1. |
l |
double |
The lightness, 0 to 1. |
Returns colour: The colour, as a colour number.
Examples
"#%06X".format(hsl(0, 1, 0.5)) → "#FF0000"
"#%06X".format(hsl(0.3333, 1, 0.5)) → "#00FF00"
hsl(0.5, 1, 0.5) → 65535
Lighter
lighter · lighter(color: colour, factor: double)
Lightens a colour by a factor, towards white. The result is a colour number; a style needs it as text: "#%06X".format(lighter(rgb(1, 0, 0), 0.5)).
Parameters
| Name | Type | Description |
|---|---|---|
color |
colour |
The colour to lighten. |
factor |
double |
How far to lighten it, 0 leaving it unchanged and 1 reaching white. |
Returns colour: The lightened colour, as a colour number.
Examples
lighter(rgb(0.5, 0, 0), 0.5) → 13660272
"#%06X".format(lighter(rgb(0.5, 0, 0), 0.5)) → "#D07070"
RGB colour
rgb · rgb(r: double, g: double, b: double)
Builds a colour from red, green and blue, each a fraction from 0 to 1: rgb(1, 0, 0) is pure red, and values of 1 and above are capped. The result is a colour number; a style needs it as text: "#%06X".format(rgb(1, 0, 0)).
Parameters
| Name | Type | Description |
|---|---|---|
r |
double |
The red component, a fraction from 0 to 1. |
g |
double |
The green component, a fraction from 0 to 1. |
b |
double |
The blue component, a fraction from 0 to 1. |
Returns colour: The colour, as a colour number.
Examples
rgb(1, 0, 0) → 16711680
"#%06X".format(rgb(0, 0.5, 1)) → "#0080FF"
rgb(128, 0, 0) → 16711680
This page describes Amtiri Script 5.4.1 as shipped with Data Orchester engine 6.12.1 and Site 1.22.7.