xxxxxxxxxx
69
// Daniel Shiffman
// http://codingtra.in
// http://patreon.com/codingtrain
// 10PRINT
// https://www.youtube.com/watch?v=bEyTZ5ZZxZs
let x = 0;
let y = 0;
let randoGuy;
let spacing;
let groundCol;
let wallCol;
let finished = false;
function setup() {
spacing = 30;//random(4, 30);
randoGuy = random(0, 5);
frameRate(60);
createCanvas(windowWidth, windowHeight);
background(0);
groundCol = color(159, 103, 59);
wallCol = color(104, 67, 39);
}
function draw() {
noStroke();
for (let i = 0; i < 5; i++) {
drawSegment();
moveSegment(spacing);
}
//noLoop();
}
function drawSegment() {
if (noise(x * y * 2) > noise(x * y)) {
//if (random(1) < 0.5) {
backslash(x, y, spacing);
} else {
forwardslash(x, y, spacing);
}
}
function moveSegment(spacing) {
x = x + spacing;
if (x > width) {
x = 0;
y = y + spacing;
if (y > height) {
y = 0;
}
}
}
function backslash(x, y, spacing) {
noStroke();
fill(wallCol);
rect(x, y, spacing, spacing);
//line(x, y, x + spacing, y + spacing);
}
function forwardslash(x, y, spacing) {
noStroke();
fill(groundCol);
rect(x, y, spacing, spacing);
//line(x, y + spacing, x + spacing, y);
}