xxxxxxxxxx
63
// inspired by Okazz
// Twitter @okazz_
let r = 20;
const directions = ["LEFT", "RIGHT", "UP", "DOWN"];
let space = 5;
function setup() {
createCanvas(590, 590, WEBGL);
// background(105);
stroke(150);
strokeWeight(0.5);
frameRate(1);
angleMode(DEGREES);
rectMode(CENTER);
}
function draw() {
background(105, 20);
translate(-270, -270);
for (let a = 0; a < height; a += 150) {
push();
translate(0, a);
for (let b = 0; b <= width; b += 150) {
push();
// rect(a, b, 100, 100);
translate(b, 0);
createSnake();
pop();
}
pop();
}
}
function createSnake() {
let x = 50;
let y = 50;
for (let j = 0; j < 10; j++) {
dir = random(directions);
for (let i = 0; i < 10; i++) {
if (dir === "LEFT" && x > 0) {
x -= space;
} else if (dir === "RIGHT" && x < 100) {
x += space;
} else if (dir === "UP" && y > 0) {
y -= space;
} else if (dir === "DOWN" && y < 100) {
y += space;
}
fill(240,5);
stroke(150);
circle(x, y, r);
// push();
// translate(50, 50);
// strokeWeight(0.1);
// sphere(x / 6);
// rotateY(millis() / 1000);
// pop();
}
}
}