51 lines
969 B
JavaScript
51 lines
969 B
JavaScript
|
const black = '#1a181a';
|
||
|
const white = '#e5c463';
|
||
|
let xScale = 0.015;
|
||
|
let yScale = 0.02;
|
||
|
|
||
|
let xOffset = 0;
|
||
|
let yOffset = 0;
|
||
|
|
||
|
let gridsize = 6;
|
||
|
let width = window.innerWidth;
|
||
|
let height = window.innerHeight;
|
||
|
|
||
|
function setup() {
|
||
|
createCanvas(width, height);
|
||
|
drawGrid();
|
||
|
}
|
||
|
|
||
|
function draw() {
|
||
|
yOffset += 0.2;
|
||
|
xOffset += 0.1;
|
||
|
drawGrid();
|
||
|
}
|
||
|
|
||
|
function drawGrid() {
|
||
|
background(black);
|
||
|
noStroke();
|
||
|
fill(white);
|
||
|
|
||
|
for (let x = 1; x < width; x += gridsize) {
|
||
|
for (let y = 1; y < height; y += gridsize) {
|
||
|
let adjustedY = + yOffset;
|
||
|
let noiseValue = noise((x + xOffset) * xScale, (adjustedY + yOffset) * yScale);
|
||
|
|
||
|
if (noiseValue >= 0.55) {
|
||
|
square(x, y, gridsize);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fill(black);
|
||
|
for (let x = 1; x < width; x += gridsize) {
|
||
|
for (let y = 1; y < height; y += gridsize) {
|
||
|
let noiseValue = noise((x + 2 * xOffset) * 2 * xScale, (y + 2 * yOffset) * 2 * yScale);
|
||
|
|
||
|
if (noiseValue >= 0.5) {
|
||
|
square(x, y, gridsize);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|