ColorGrid

ABSTRACT

Generates a color grid mesh based on specified parameters. A color grid is essentially a set of small rectangles, and each rectangle in the grid gets its color from a user provided function. Moreover, you can mask out only a subset of the rectangles to be shown. The key feature is that this all provided in a single mesh, which basically makes this significantly more perfamant than creating 10000 rectangles as you might do otherwise.

IMPORTANT ELEMENT

A color grid is extremely versatile and we recommend you play around with it. In particular, it's great for creating parameteric surfaces in conjunction with PointMapped (this is how the Monocurl log was created). You might also want to refer to keyframe_lerp for help on creating gradients.

PARAMETERS
x_minDefine the minimum x-coordinate of the grid
x_maxDefine the maximum x-coordinate of the grid
y_minDefine the minimum y-coordinate of the grid
y_maxDefine the maximum y-coordinate of the grid
x_minDefine the minimum x-coordinate of the grid
x_maxDefine the maximum x-coordinate of the grid
y_minDefine the minimum y-coordinate of the grid
y_maxDefine the maximum y-coordinate of the grid
x_stepDefine the step size for x-coordinate (how wide each sub rectangle should be)
y_stepDefine the step size for y-coordinate (how tall each sub rectangle should be)
x_minDefine the minimum x-coordinate of the grid
x_maxDefine the maximum x-coordinate of the grid
y_minDefine the minimum y-coordinate of the grid
y_maxDefine the maximum y-coordinate of the grid
x_stepDefine the step size for x-coordinate (how wide each sub rectangle should be)
y_stepDefine the step size for y-coordinate (how tall each sub rectangle should be)
mask(pos)Function to define mask for specific positions (whether or not a sub rectangle should be included or not). Return 1 if it should be used, and zero otherwise.
tagA vector of numbers used as the mesh's tag
color_at(pos)Function to define color at specific positions. Pos is a 3-vector consisting of the global x, y, and z positions.
color_at(pos)Function to define color at specific positions. Pos is a 3-vector consisting of the global x, y, and z positions.
strokeA 4-vector representing the color of the grid's stroke (defaults to white)
RETURN

a color grid mesh based on the above specification

DECLARATION
func ColorGrid([points] {[main] {x_min, x_max, y_min, y_max}, [step] {x_min, x_max, y_min, y_max, x_step, y_step}, [mask] {x_min, x_max, y_min, y_max, x_step, y_step, mask(pos)}}, tag, [color] {[auto_stroke] {color_at(pos)}, [custom_stroke] {color_at(pos), stroke}})