FlowscopeDocs

color reference

Colours, gradients and colour scales.

Colours are #RRGGBB or #RRGGBBAA literals or built with color.rgb. color.up and color.down follow the chart’s candle colours; color.gradient and color.scale map values to colours.

Functions

color.a

Flowscope Script
color.a(c: color) -> int

Returns the alpha channel from a color.

c must be a non-null color. The result is the non-null alpha channel as an integer in the 0..=255 range. Six-digit hex colors have alpha 255; eight-digit hex colors carry their explicit alpha value.

ParameterType
ccolor

Returns int

color.b

Flowscope Script
color.b(c: color) -> int

Returns the blue channel from a color.

Returns the blue value of c as an integer from 0 to 255. Check for null or use ?? before passing a nullable color.

ParameterType
ccolor

Returns int

color.darken

Flowscope Script
color.darken(c: color, percent: float) -> color

Darkens a color by mixing it toward black.

c is the starting color. percent sets how much to mix it toward black. The result is a non-null color with valid color-channel values.

Check for null or use ?? before passing nullable inputs.

ParameterType
ccolor
percentfloat

Returns color

color.g

Flowscope Script
color.g(c: color) -> int

Returns the green channel from a color.

Returns the green value of c as an integer from 0 to 255. Check for null or use ?? before passing a nullable color.

ParameterType
ccolor

Returns int

color.gradient

Flowscope Script
color.gradient(value: float, bottom: float, top: float, start: color, end: color) -> color

Blends between two colors based on a number.

value chooses a position between bottom and top. Values are clamped to that range without an error.

Returns start below the range or when bottom == top, and end above the range. Between the bounds, red, green, blue, and opacity change linearly. The result uses valid color-channel values.

Check for null or use ?? before passing nullable numbers or colors.

ParameterType
valuefloat
bottomfloat
topfloat
startcolor
endcolor

Returns color

color.lighten

Flowscope Script
color.lighten(c: color, percent: float) -> color

Lightens a color by mixing it toward white.

c is the starting color. percent sets how much to mix it toward white. The result is a non-null color with valid color-channel values.

Check for null or use ?? before passing nullable inputs.

ParameterType
ccolor
percentfloat

Returns color

color.r

Flowscope Script
color.r(c: color) -> int

Returns the red channel from a color.

Returns the red value of c as an integer from 0 to 255. Check for null or use ?? before passing a nullable color.

ParameterType
ccolor

Returns int

color.rgb

Flowscope Script
color.rgb(r: int, g: int, b: int, a: int = 255) -> color

Creates a color from red, green, blue, and opacity values.

r, g, and b each use an integer from 0 to 255. Out-of-range values are clamped to the nearest end of that range.

a sets opacity from 0 (transparent) to 255 (opaque) and defaults to 255. For example, color.rgb(17, 34, 51) equals #112233. All inputs must be non-null integers; fractions are not accepted.

ParameterType
rint
gint
bint
aint

Returns color

color.scale

Flowscope Script
color.scale(at: float[], colors: color[], space: ColorSpace = 2, easing: Easing = 1) -> ColorScale

Creates a color scale from a list of positions and colors.

Define the scale during setup, then read colors with .sample.

  • at lists positions in ascending order. colors lists the matching colors. Both setup arrays need the same length and at least two entries.
  • space chooses colorspace.rgb or colorspace.hsl, defaulting to HSL.
  • easing chooses how colors change between positions: easing.linear, easing.smoothstep, or easing.smootherstep. The default is linear.

Positions must be finite and cannot descend; invalid lists are rejected before the script runs. Equal adjacent positions create a sharp color change: the earlier color applies at that position, and the later color applies beyond it. Opacity always changes linearly.

The scale cannot be saved in state or passed to other calls. Use its .sample method to read it.

ParameterType
atfloat[]
colorscolor[]
spaceColorSpace
easingEasing

Returns ColorScale

Available in Setup only: declarations, setup and state initialisers.

color.withAlpha

Flowscope Script
color.withAlpha(c: color, a: int) -> color

Changes a color’s opacity.

c supplies the color. a sets opacity from 0 (transparent) to 255 (opaque). It is an integer, not a percentage. Out-of-range values are clamped to 0 or 255.

Check for null or use ?? before passing a nullable color.

ParameterType
ccolor
aint

Returns color

Methods

colorscale.sample

Flowscope Script
colorscale.sample(t: float) -> color

Reads a color from a scale at a position.

t chooses the position. Values outside the scale are clamped: below it returns the first color, above it returns the last. Null or NaN also returns the first color without an error.

Between positions, the scale’s easing and color space determine the blend. HSL takes the shortest path around the color wheel. A gray endpoint uses the other endpoint’s hue. Opacity changes linearly in every color space.

ParameterType
tfloat

Returns color

Available in Handlers and functions called from handlers.

Constants

ConstantTypeValueDescription
color.ambercolor#f59e0bAmber (#f59e0b).
color.blackcolor#000000Black (#000000).
color.bluecolor#466be5Blue (#466be5).
color.browncolor#a52a2aBrown (#a52a2a).
color.cyancolor#00eeffCyan (#00eeff).
color.downcolor#e81f59Bearish red (#e81f59).
color.emeraldcolor#16c784Emerald (#16c784).
color.graycolor#808080Gray (#808080).
color.greencolor#00ff00Green (#00ff00).
color.indigocolor#2962ffIndigo (#2962ff).
color.lightskybluecolor#87cefaLight sky blue (#87cefa).
color.magentacolor#ff00ffMagenta (#ff00ff).
color.marooncolor#800000Maroon (#800000).
color.navycolor#000080Navy (#000080).
color.olivecolor#808000Olive (#808000).
color.orangecolor#ffa500Orange (#ffa500).
color.pinkcolor#ffc0cbPink (#ffc0cb).
color.purplecolor#800080Purple (#800080).
color.redcolor#e81f59Red (#e81f59).
color.silvercolor#9e9e9eSilver (#9e9e9e).
color.tealcolor#008080Teal (#008080).
color.transparentcolor#00000000Fully transparent black (#00000000).
color.upcolor#00ff00Bullish green (#00ff00).
color.whitecolor#ffffffWhite (#ffffff).
color.yellowcolor#ffff00Yellow (#ffff00).
colorspace.hslColorSpace2HSL color-scale interpolation with shortest-path hue.
colorspace.rgbColorSpace1RGB color-scale interpolation by channel.
easing.linearEasing1Linear segment easing, leaving the local position unchanged.
easing.smootherstepEasing3Smootherstep segment easing with ttt*(t*(6t-15)+10).
easing.smoothstepEasing2Smoothstep segment easing with tt(3-2t).