canvas = createCanvas(800, 800, WEBGL);
colorMode(HSB, 360, 100, 100, 100);
ortho(-width / 2, width / 2, -height / 2, height / 2, -5000, 5000);
while (palette.length < 5) {
palette = shuffle(chromotome.get().colors);
directionalLight(color(0, 0, 80), 1, 0, -1);
directionalLight(color(0, 0, 30), -1, 0, -1);
directionalLight(color(0, 0, 50), 0, 1, 0);
let w = sqrt(width * width + height * height);
let d = w * 2 + offset * 2;
translate(0, height / 5, 0);
separateGrid(x, y, d, minD);
function separateGrid(x, y, d, minD) {
let sep = int(random(1, 5));
translate(x + d / 2, y + d / 2);
scale(random() > 0.5 ? -1 : 1, random() > 0.5 ? -1 : 1);
rotate((int(random(4)) * 360) / 4);
translate(-d / 2, -d / 2);
for (let j = 0; j < sep; j++) {
for (let i = 0; i < sep; i++) {
if (random(100) < 98 && w > minD) {
separateGrid(nx, ny, w, minD);
function pixelRect(x, y, w, h, c) {
let colors = shuffle(palette.concat());
let density = pow(2, int(random(2, 6)));
let g = createGraphics(density, density);
let gradient = g.drawingContext.createLinearGradient(0, 0, 0, g.height);
for (let i = 0; i < colors.length; i++) {
let step = map(i, 0, colors.length - 1, 0, 1);
gradient.addColorStop(step, colors[i]);
g.drawingContext.fillStyle = gradient;
g.rect(0, 0, width, height);
for (let p = 4; p < colors.length; p++) {
switch (int(random(1, 5))) {
for (let i = 0; i < density; i++) {
for (let i = 0; i < density; i++) {
g.rect(i, 0, 1, g.height);
for (let j = 0; j < density; j++) {
for (let i = 0; i < density; i++) {
if (j % 2 == (j + k) % 2) {
for (let i = 0; i < density; i++) {
for (let j = i; j < density; j++) {
for (let j = 0; j < density; j++) {
for (let i = 0; i < density; i++) {
let tex = canvas.getTexture(g);
tex.setInterpolation(NEAREST, NEAREST);
let bh = random(w / 2, w * 5);
translate(x + w / 2, y + w / 2, -bh / 2);
scale(random() > 0.5 ? -1 : 1, random() > 0.5 ? -1 : 1);
rotate((int(random(4)) * 360) / 4);