Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Tuple Aliases

Some named tuples are used frequently and thus they have aliases: Color, Vec2 and Vec3. This feature is also called named-tuple duck-typing.

Color

A named tuple with the fields r, g, b and a will be treated as a color with red, green, blue and alpha channel. You can use the type alias Color to deal with color values.

test

color: Color = (r = 100%, g = 50%, b = 25%, a = 100%);

std::debug::assert(color.r == 100%);

Vec2

A named tuple with the fields x and y will be treated as a two-dimensional vector. You can use the type alias Vec2.

test

v: Vec2 = (x = 2.0, y = 3.0);

std::debug::assert(v.x + v.y == 5.0);

Vec3

A named tuple with the fields x, y and z will be treated as a three-dimensional vector. You can use the type alias Vec3.

test

v: Vec3 = (x = 2.0, y = 3.0, z = 4.0);

std::debug::assert(v.x + v.y + v.z == 9.0);