float hexRad, hexHeight; float heightRatio; void setup() { heightRatio = sqrt(pow(0 - sin(2*2*PI/6), 2) + pow(1 - cos(2*2*PI/6), 2)); size(500,500); hexHeight = width/2; hexRad = hexHeight / heightRatio; smooth(); noLoop(); colorMode(HSB, 1); } void drawHexagon(float cx, float cy, float r) { beginShape(POLYGON); for (int i = 0; i < 6; ++i) { float a = i*2*PI/6; vertex(cx+sin(a)*r,cy+cos(a)*r); } endShape(); } void draw() { background(0,0,0); float r = hexRad; float cx = hexHeight/2; float cy = hexRad; fill(0,.25,.75); drawHexagon(hexHeight/2, hexRad, r); fill(0,.25,.70); drawHexagon(3*hexHeight/2, hexRad, r); fill(0,.25,.65); drawHexagon(width/2, hexRad*2.5, r); } // save("hexagon.tiff");