Skip to content

Instantly share code, notes, and snippets.

// "number in box" - try clicking in the window
// this is the "data"
var c = 0;
var x = 50;
var y = 50;
function setup() {
createCanvas(340, 340);
}
rect(50, 50, 200, 200);
rect(50+10, 50+10, 200, 200);
rect(50+20, 50+20, 200, 200);
rect(50, 50, 200, 200);
rect(60, 60, 200, 200);
rect(70, 70, 200, 200);
rect(70, 70, 200, 200);
rect(width/2 - 100, height/2 - 100, 200, 200);
var offset = 100;
rect(width/2 - offset, height/2 - offset, offset*2, offset*2);
offset = 90;
rect(width/2 - offset, height/2 - offset, offset*2, offset*2);
for (var x = 10; x < width; x += 20) {
line(x, 10, x, height-10);
}
for (var x = 10; x < width; x += 20) {
if (x < width/2) {
line(x, 10, x, height/2);
} else {
line(x, height-10, x, height/2);
}
}
function happyFace(x, y) {
// head
ellipse(x, y, 100, 100);
// eyes
ellipse(x-20, y-25, 20, 20);
ellipse(x+20, y-25, 20, 20);
// nose
line(x, y-20, x-10, y);
// "spaced colored squares" -- object edition
colorMode(HSB);
noFill();
var SIZE = 40;
var squares = [];
for (var x = 50; x <= 250; x = x + 50) {
// "spaced colored squares" -- array edition
colorMode(HSB);
noFill();
var SIZE = 40;
var xs = [50, 100, 150, 200, 250];
var y = height/2 - SIZE/2;
// "spaced colored squares" -- array edition
colorMode(HSB);
noFill();
var SIZE = 40;
var y = height/2 - SIZE/2;
var squares = [
{ x: 50, y: y },
// "spaced colored squares" -- object edition
var squares = [];
function setup() {
colorMode(HSB);
noFill();
for (var x = 50; x <= 250; x = x + 50) {
squares.push({