fractalkitty looking for math? fractalkitty.com

Mathober 2024

antiprism

#grid#color#text#interactive#animation#math#geometry#tiling#mathober

bgColgColnGridgSpacedrawGrid

const bgCol = "#447abd";
const gCol = "#a2c2e8";
const nGrid = 20;
let w;
let gSpace;

function setup() {
  w = max(400, min(windowWidth, windowHeight) * 0.9);
  gSpace = (w / nGrid) * 0.95;
  describe(
    "4 aperigonal antiprism tilings moving in alternating directions horizontally across the screen on a blueprint design. "
  );
  createCanvas(w, w);
  rectMode(CENTER);

  d = w;
  angleMode(DEGREES);
  textSize(16);
}

function draw() {
  background(bgCol);
  translate(w / 2, w / 2);
  drawGrid();
  t = frameCount / 3;
  noStroke();
  for (let j = 0; j < 4; j++) {
    push();
    translate(0, -8 * gSpace + j * gSpace * 4.33);
    fill(255, 255, 255, 150);
    rect(0, 1.5 * gSpace, w, 2 * gSpace);
    stroke(255);
    strokeWeight(1);
    fill(255, 255, 255, 50);
    rect(0, 0, w, gSpace);
    rect(0, 3 * gSpace, w, gSpace);
    stroke(255);
    strokeWeight(2);
    fill(255, 255, 255, 20);
    t1 = (pow(-1, j % 2) * t) % (2 * gSpace);
    for (let i = -w / 2 - gSpace; i < w / 2; i += 2 * gSpace) {
      line(i + t1, 0.5 * gSpace, i + gSpace + t1, 2.5 * gSpace);
      line(i + gSpace + t1, 2.5 * gSpace, i + 2 * gSpace + t1, 0.5 * gSpace);
    }
    pop();
  }

  noStroke();
  noStroke();
  fill(bgCol);
  rect(-width / 2 + gSpace / 2, 0, gSpace, height);
  rect(width / 2 - gSpace / 2, 0, gSpace, height);
  rect(0, -width / 2 + gSpace / 2, height, gSpace);
  rect(0, width / 2 - gSpace / 2, height, gSpace);

  fill(gCol);
  text("antiprism", -w / 2 + 10, w / 2 - 5);
}

function drawGrid() {
  stroke(gCol);
  strokeWeight(0.3);
  for (let i = 1; i <= nGrid; i++) {
    for (let j = 1; j <= nGrid; j++) {
      line(
        -w / 2 + gSpace * i,
        -w / 2 + gSpace,
        -w / 2 + gSpace * i,
        w / 2 - gSpace
      );
      line(
        -w / 2 + gSpace,
        -w / 2 + gSpace * i,
        w / 2 - gSpace,
        -w / 2 + gSpace * i
      );
    }
  }
  noFill();
  strokeWeight(3);
  rect(0, 0, w - 2 * gSpace);
}

function mousePressed() {
  setup();
  draw();
}
function windowResized() {
  setup();
  draw();
}