Skip to content

Common datatypes

There are a number of common datatypes available in expressions. These allow users to work with compound values more easily.

Colour

The function Colour(r, g, b, a) allows the creation of a Colour object. This object has r, g, b, a fields, which are floating point values, which are expected to be between 0 and 1.

Colour.mix(otherCol, ratio)

Mixing Colour values is a common operation. The mix function performs a lerp on each of the r, g, b, a components using the given ratio. An example expression should help explain how it is used:

Colour(1, 0, 0, 1).mix(Colour(0, 1, 0, 1), 0.5)

This produces a Colour value which contains r=0.5, g=0.5, b=0.0, a=1.0, which can then be referenced elsewhere in the system.

ColourFromHSL(hue, saturation, lightness)

This function is convenient for creating a colour value from a Hue, Saturation, Lightness wheel representation of colour. It produces a regular Colour object which contains RGB components which correspond to the HSL values. For example ColourFromHSL(0.0, 1.0, 1.0) is equivalent to Colour(1.0, 0.0, 0.0, 1.0) because the 0 degree hue is a red primary.

  • Hue is a float value representing the number of degrees around the edge of a colour wheel. The value is between 0 and 360 (which are equivalent to one another).
  • Saturation is a float value from 0 to 1. As the value approaches 0, the resulting colour approaches the Lightness value in grey.
  • Lightness is the intensity of the colour. It is also a value from 0 to 1, where 0 is black, and 1 is full intensity. This is also called ‘value’ in some software.

Vec2 (float2)

The function Vec2(x, y) allows the creation of a Vec2 object. This object has x, y fields, which are floating point values.

Vec2 is aliased by float2 for convenience.

Vec3 (float3)

The function Vec3(x, y, z) allows the creation of a Vec3 object. This object has x, y, z fields, which are floating point values.

Vec3 is aliased by float3 for convenience.

Vec4 (float4)

The function Vec4(x, y, z, w) allows the creation of a Vec4 object. This object has x, y, z, w fields, which are floating point values.

Vec4 is aliased by float4 for convenience.

Vector functions

The Vec<N> family of data types have a number of convenience functions exposed:

v1.dot(v2)

Performs the dot product between 2 vectors.

v1.abs()

Provides the absolute value of the components.

Vector properties

Vector types have computed properties, as well as functions. These are accessed without calling.

v1.minComponent

Provides the minimum value of the components

v1.maxComponent

Returns the minimum value of the components.