0x57ca1267…d46csent to0xf28f163e…abec·#21,460,221·view on Etherscan
https://ipfs.io/ipfs/QmaR8Uz3pKvRucSUc9Cnu8rqovzmhL1jeVcey9Wx1NP6V1let scaleRange = {min: 0.05, max: 0.12}, rarities = {vertical: 0.1, horizontal: 0.1, xShape: 0.03, outline: 0.01, empty: 0.59, fillColor: 0.01}, blackCellPercentage = 0.8, bgHexColors = [], bgHexSize, hueStart;
function setup() {colorMode(HSB, 360, 100, 100); createCanvas(windowWidth, windowHeight); hueStart = random(360); noLoop(); drawGrid();}
function initBgHexColors(mainHexSize) {bgHexColors = []; bgHexSize = mainHexSize / 4; let w = sqrt(3) * bgHexSize, h = 1.5 * bgHexSize; for (let y = 0, i = 0; y < height + h; y += h, i++) {let row = []; for (let x = 0; x < width + w; x += w) row.push({x: x + (i % 2 ? w / 2 : 0), y, color: color((hueStart + random(20)) % 360, random(50, 100), random(0, 70), 0.5)}); bgHexColors.push(row);}}
function drawGrid() {background(0); let hexSize = random(scaleRange.min, scaleRange.max) * min(width, height), w = sqrt(3) * hexSize, h = 1.5 * hexSize; initBgHexColors(hexSize); drawBgHexLayer(); stroke(255); strokeWeight(min(width, height) * 0.002); for (let y = 0, i = 0; y < height + h; y += h, i++) for (let x = 0; x < width + w; x += w) drawHexCell(x + (i % 2 ? w / 2 : 0), y, hexSize, random() < blackCellPercentage);}
function drawBgHexLayer() {noStroke(); bgHexColors.forEach(row => row.forEach(h => (fill(h.color), drawHexAt(h.x, h.y, bgHexSize))));}
function drawHexCell(x, y, r, isBlack) {
push();
translate(x, y);
if (isBlack) {
fill(0);
noStroke();
drawHex(r);
}
let c = randomType(rarities);
if (c === 'vertical') drawLine(0, -r, 0, r);
else if (c === 'horizontal') drawLine(-sqrt(3) / 2 * r, 0, sqrt(3) / 2 * r, 0);
else if (c === 'xShape') drawX(r);
else if (c === 'fillColor') {
fill(0, 0, 100);
noStroke();
drawHex(r);
}
if (c === 'outline') drawHex(r);
if (c !== 'outline') drawEdges(r);
pop();
}
function drawHex(r) {beginShape(); for (let i = 0; i < 6; i++) vertex(cos((TWO_PI / 6) * i - PI / 6) * r, sin((TWO_PI / 6) * i - PI / 6) * r); endShape(CLOSE);}
function drawHexAt(x, y, r) {push(); translate(x, y); drawHex(r); pop();}
function drawX(r) {drawLine(-sqrt(3) / 2 * r, -r / 2, sqrt(3) / 2 * r, r / 2); drawLine(-sqrt(3) / 2 * r, r / 2, sqrt(3) / 2 * r, -r / 2);}
function drawLine(x1, y1, x2, y2) {stroke(255); line(x1, y1, x2, y2);}
function drawEdges(r) {stroke(200); for (let i = 0, s = []; i < int(random(1, 3)); i++) {let ed; do ed = int(random(6)); while (s.includes(ed)); s.push(ed); let a1 = (TWO_PI / 6) * ed - PI / 6, a2 = (TWO_PI / 6) * ((ed + 1) % 6) - PI / 6; drawLine(cos(a1) * r, sin(a1) * r, cos(a2) * r, sin(a2) * r);}}
function randomType(w) {let t = Object.values(w).reduce((a, b) => a + b, 0), p = random(t), c = 0; for (let k in w) if ((c += w[k]) > p) return k;}
function mousePressed() {hueStart = random(360); drawGrid();}
function windowResized() {resizeCanvas(windowWidth, windowHeight); drawGrid();}