Grid

Grid #

A grid is a surface with a simple squared tessellation. It can be used to mesure and object’s size, movement and rotation if placed in a relative point.

Params #

NamePropTypedescription
subdivisionsnumberSubdivision number.
sizenumberGrid’s size.
shapenumberThe grid can be dotted (using Tree.DOTS) or solid (using Tree.SOLID). Default is dotted.

Showcase #

Click and drag to move the camera arround!

code #

sketch.js
// gui params
var subdivisions = 10;
var size = 250;
var style = ['Tree.DOTS', 'Tree.SOLID'];
var selectedstyle;

var gui;

function setup() {
	createCanvas(400, 400, WEBGL);
	setAttributes('antialias', true);

	easycam = createEasyCam();
	easycam.setZoomScale(false);

	gui = createGui('Double click to close');

	gui.addGlobals('subdivisions', 'size', 'style');
}

function draw() {
	// pick a style
	switch (style) {
		case 'Tree.SOLID':
			selectedStyle = Tree.SOLID;
			break;

		default:
			selectedStyle = Tree.DOTS;
			break;
	}

	background(255);
	stroke(0);
	strokeWeight(4);

	push();
	grid({ subdivisions, size, style: selectedStyle });
	pop();
}