🎨
Xylo Docs
  • Introduction
  • Getting Started
    • Quickstart
  • Guides
    • Random Rotations
  • Syntax
    • Primitives
    • Functions
  • Control Flow
  • Builtin Functions
    • System
    • Math
    • Comparison
    • List
    • Randomness
    • Shape
    • Color
Powered by GitBook
On this page
  • HSL Functions
  • RGB Functions
  • Gradient Functions
Export as PDF
  1. Builtin Functions

Color

HSL Functions

hsl n1 n2 n3 shape

Returns shape with its color set to n1 for hue, n2 for saturation, and n3 for lightness. n1, n2, and n3 must be of the integer or float types and shape must be of the shape type.

Example:

magenta_square = hsl 280 0.9 0.75 SQUARE

hsla n1 n2 n3 n4 shape

Returns shape with its color set to n1 for hue, n2 for saturation, n3 for lightness, and n4 for alpha. n1, n2, n3 and n4 must be of the integer or float types and shape must be of the shape type.

Example:

transparent_magenta_square = hsla 280 0.9 0.75 0.5 SQUARE

h n shape

Returns shape with its hue set to n. n must be of the integer or float types and shape must be of the shape type.

Shorthand for the hue function.

Example:

white_cyan_square = h 180 SQUARE
white_cyan_square = hue 180 SQUARE

sat n shape

Returns shape with its saturation set to n. n must be of the integer or float types and shape must be of the shape type.

Shorthand for the saturation function.

Example:

white_gray_square = sat 0 SQUARE
white_gray_square = saturation 0 SQUARE

l n shape

Returns shape with its lightness set to n. n must be of the integer or float types and shape must be of the shape type.

Shorthand for the lightness function.

Example:

red_square = l 0.5 SQUARE
red_square = lightness 0.5 SQUARE

a n shape

Returns shape with its alpha set to n. n must be of the integer or float types and shape must be of the shape type.

Shorthand for the alpha function.

Example:

transparent_white_square = a 0.5 SQUARE
transparent_white_square = alpha 0.5 SQUARE

hshift n shape

Returns shape with its hue shifted by n. n must be of the integer or float types and shape must be of the shape type.

Example:

white_cyan_square = hshift 180 SQUARE

satshift n shape

Returns shape with its saturation shifted by n. n must be of the integer or float types and shape must be of the shape type.

Example:

white_gray_square = satshift -1 SQUARE

lshift n shape

Returns shape with its lightness shifted by n. n must be of the integer or float types and shape must be of the shape type.

Example:

red_square = lshift -0.5 SQUARE

ashift n shape

Returns shape with its alpha shifted by n. n must be of the integer or float types and shape must be of the shape type.

Example:

transparent_white_square = ashift -0.5 SQUARE

RGB Functions

hex color shape

Returns shape with its color set to color. color must be of the hexadecimal type and shape must be of the shape type.

Example:

neon_green_square = hex 0x39ff14 SQUARE

Gradient Functions

solid shape

Returns shape with its gradient removed and its color set to a solid white.

Example:

white_square = solid (g (linear_grad -1 -1 1 1) SQUARE)

g grad shape

Returns shape with its gradient set to grad.

Shorthand for the gradient function.

Example:

gradient_square = g (linear_grad -1 -1 1 1) SQUARE
gradient_square = gradient (linear_grad -1 -1 1 1) SQUARE

linear_grad start_x start_y end_x end_y

Returns a gradient object with a linear transition from (start_x, start_y) to (end_x, end_y). Accepts integer and float types.

Example:

linear_gradient = linear_grad 0.5 1 0.5 -1

radial_grad start_x start_y end_x end_y radius

Returns a gradient object with a radial transition from (start_x, start_y) to (end_x, end_y) and a radius of radius. Accepts integer and float types.

Example:

radial_gradient = radial_grad 0 0 1 1 1

grad_start x y grad

Returns grad with its start position set to (x, y). x and y must be of the integer or float types.

Example:

corner_to_corner = grad_start -1 -1 (linear_gradient 0 0 1 1)

grad_end x y grad

Returns grad with its end position set to (x, y). x and y must be of the integer or float types.

Example:

corner_to_corner = grad_end 1 1 (linear_gradient -1 -1 0 0)

to_linear_grad grad

Converts grad to a linear gradient.

Example:

linear_gradient = to_linear_grad (radial_grad 0.5 1 0.5 -1 1)

grad_radius radius grad

Returns grad with its radius set to radius, converting it to a radial gradient if necessary. radius must be of the integer or float types.

Example:

linear_gradient = to_linear_grad (radial_grad 0.5 1 0.5 -1 1)

grad_stop_hsl pos n1 n2 n3 grad

Returns grad with its color at position pos set to n1 for hue, n2 for saturation, and n3 for lightness. pos, n1, n2, and n3 must be of the integer or float types.

Example:

red_to_blue =
    grad_stop_hsl 0 0 1 0.5 (
    grad_stop_hsl 1 210 1 0.5 (
    linear_grad 0.5 1 0.5 -1))

grad_stop_hsla pos n1 n2 n3 n4 grad

Returns grad with its color at position pos set to n1 for hue, n2 for saturation, n3 for lightness, and n4 for alpha. pos, n1, n2, n3, and n4 must be of the integer or float types.

Example:

red_to_faded_blue =
    grad_stop_hsl 0 0 1 0.5 (
    grad_stop_hsla 1 210 1 0.5 0.5 (
    linear_grad 0.5 1 0.5 -1))

grad_stop_hex pos color grad

Returns grad with its color at position pos set to n1 for hue, n2 for saturation, and n3 for lightness. pos, n1, n2, and n3 must be of the integer or float types.

Example:

red_to_blue =
    grad_stop_hex 0 0xf00 (
    grad_stop_hex 1 0x00f (
    linear_grad 0.5 1 0.5 -1))

grad_spread_mode sm grad

Returns grad with its spread mode set the sm.

Example:

reflected = grad_spread_mode SPREAD_MODE_REFLECT (linear_grad -1 -1 0 0)
PreviousShape

Last updated 1 day ago

Refer to for a full list of possible spread modes.

Spread Mode