xxxxxxxxxx
function setup() {
createCanvas(800, 800);
colorMode(HSB, 360);
background(360);
noLoop();
}
function draw() {
translate(width * 0.5, height * 0.5);
scale(360);
strokeWeight(0.005);
stroke(0);
noFill();
// Draw hexagons of radius 1
hexagon(0, 0, 1, TAU);
// hexagon(0, 0, 1, PI / 2);
// Add circumscribing ellipses
ellipse(0, 0, 2);
ellipse(0, 0, sin(PI / 3) * 2);
// Distance between these two circles is:
var distance = 1 - sin(PI / 3);
point(0, 1 - distance);
strokeWeight(0.0025);
// ellipse(0, 1 - distance / 2, sin(PI / 24));
strokeWeight(0.005);
var distance2 = sin(1) * distance;
var distance4 = sin(PI/3) + distance2;
ellipse(0, distance4, sin(PI / 26));
}
function hexagon(x, y, radius, startRotation) {
push();
translate(x, y);
beginShape();
for (let a = 0; a < TAU; a += TAU / 6) {
let sx = sin(a + startRotation) * radius;
let sy = cos(a + startRotation) * radius;
vertex(sx, sy);
}
endShape(CLOSE);
pop();
}