xxxxxxxxxx
93
let noiseScale = 0.2;
let w, img;
const SEED = 99;
const NOISE_SEED = 99;
function preload() {
img = loadImage("./d.jpg");
}
const sea = "#408BC2";
const palette = ["#BC903E", "#E1C500", sea, "#5B891D", "#9EB600", "#959595"];
function setup() {
createCanvas(800,800);
randomSeed(SEED);
noiseSeed(NOISE_SEED);
gridWidth = width;
gridHeight = height;
hexagonSize = height / 9;
}
function drawHexagon(cX, cY, radius) {
const type = random(palette);
textStyle(BOLD)
fill(type);
beginShape();
for (let a = 0; a < TAU; a += TAU / 6) {
vertex(cX + radius * cos(a), cY + radius * sin(a));
}
endShape(CLOSE);
if (type != sea) {
push()
translate(cX, cY,)
fill("yellow");
stroke("darkgray");
circle(0,0, 25);
const n = random([2,
3,3,
4,4,4,
5,5,5,5,
6,6,6,6,6,
8,8,8,8,8,
9,9,9,9,
10,10,10,
11,11,
12])
fill(n==8||n==6? 'red':'black')
noStroke()
rotate(random(PI));
text(""+n, -5,+5)
if (n==6 || n==9){
stroke('black')
line(-4,7,3,7)
}
pop()
}
}
function makeGrid() {
let count = 0;
for (y = 0; y < gridHeight + hexagonSize / 2.3; y += hexagonSize / 2.3) {
for (x = 0; x < gridWidth + hexagonSize / 2.3; x += hexagonSize * 1.5) {
cx = x + hexagonSize * (count % 2 == 0) * 0.75;
cy = y;
drawHexagon(
x + hexagonSize * (count % 2 == 0) * 0.75,
y,
hexagonSize / 2
);
}
count++;
}
}
function draw() {
stroke(200);
noFill();
makeGrid();
noLoop();
}