fractalkitty looking for math? fractalkitty.com

Mathober 2025

Hexyl

#random#trig#grid#interactive#animation#math#geometry#polar#mathober

linesdrawGrid


let t = 0;
let n = 25;

function setup() {
  createCanvas(500, 500);
  background(255);
  describe(
    "zigzags of 6 nodes drawn along arcs on radial graph paper with circles on the notes and lines between. There are a random number drawn at various radii, where the smallest radii are almost star-like. "
  );
  rectMode(CENTER);
  strokeWeight(0.5);
  strokeCap(SQUARE);
  rs = [];
  l = 100;
  k = 7;
  d = width / 25;
  rand1 = random([8, 10, 12, 6]);
}

function draw() {
  background(245, 250, 255, 20);
  translate(width / 2, height / 2);

  stroke(100, 110, 120, 10);

  drawGrid();
  t += 0.00008;
  noFill();
  stroke(60, 70, 80, 20);
  push();
  rotate((rand1 * 2 * PI) / 25);
  for (let j = 1; j < rand1; j += 2) {
    for (let m = 3; m < 10; m += 2) {
      r = m * d;
      r2 = (m - 1) * d;
      g = m * m;

      beginShape();
      for (let i = 0; i < 6; i++) {
        if (i % 2 === 0) {
          fill(80, 90, 100, 20);
          circle(
            r * cos(((2 * PI) / g) * i * j + t + (j * PI) / g),
            r * sin(((2 * PI) / g) * i * j + t + (j * PI) / g),
            10
          );
          noFill();
          vertex(
            r * cos(((2 * PI) / g) * i * j + t + (j * PI) / g),
            r * sin(((2 * PI) / g) * i * j + t + (j * PI) / g)
          );
        } else {
          fill(80, 90, 100, 20);
          circle(
            r2 * cos(((2 * PI) / g) * i * j + t + (j * PI) / g),
            r2 * sin(((2 * PI) / g) * i * j + t + (j * PI) / g),
            10
          );
          noFill();
          vertex(
            r2 * cos(((2 * PI) / g) * i * j + t + (j * PI) / g),
            r2 * sin(((2 * PI) / g) * i * j + t + (j * PI) / g)
          );
        }
      }
      endShape();
    }
  }

  pop();
  strokeWeight(1);
  noFill();
  stroke(100, 110, 120, 30);
  rect(0, 0, width / 1.02, width / 1.02);
  rect(0, 0, width / 1.04, width / 1.04);
}

function lines(m, x1, x2, pt) {
  let y1 = m * (x1 - pt.x) + pt.y;
  let y2 = m * (x2 - pt.x) + pt.y;
  stroke(50, 60, 70, 20);
  line(x1, y1, x2, y2);
}

function drawGrid() {
  for (let i = 0; i < n; i++) {
    rotate((2 * PI) / n);
    line(-width / 1.5, 0, width / 1.5, 0);
    circle(0, 0, (width / n) * 2 * i);
  }
  noStroke();
  for (let i = 0; i < 100; i++) {
    x = random(-width / 2, width / 2);
    y = random(-width / 2, width / 2);
    fill(245, 250, 255, 50);
    circle(x, y, 2);
  }
}

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