Skip to contentCREATIVE·CODE·ART
1
420
1.2
p5.js

Petal Storm

A phyllotaxis flower that keeps re-blooming. Hundreds of petals ride the golden angle while the twist slowly bends the spiral. Built as the live example for the p5.js guide.

Licence: CC BY-NC-SA 4.0: remix with credit, non-commercial, share alike

Editions

0 of 10 collected

Free, numbered copies of this work. Anyone signed in can collect one. Every edition runs the same code from a different starting number (its seed), so each one looks a little different, and each belongs to one person.

Sign in to collect an edition

Editions are free keepsakes. They're never sold or transferred.

View the code
function setup() {
  createCanvas(600, 600);
  colorMode(HSB, 360, 100, 100, 100);
  noStroke();
}
function draw() {
  background(235, 35, 7, 16);
  const t = frameCount * 0.008 * params.speed;
  const n = int(params.count);
  translate(width / 2, height / 2);
  for (let i = n; i > 0; i--) {
    const f = i / n;
    const a = i * (137.5 + params.twist * sin(t * 0.7)) + t * 30;
    const r = 265 * sqrt(f);
    const x = r * cos(a);
    const y = r * sin(a);
    const hue = (200 + 140 * f + frameCount * 0.4) % 360;
    const s = 4 + 15 * (1 - f) * (0.75 + 0.25 * sin(t * 2 + i * 0.35));
    fill(hue, 75, 100, 85);
    push();
    translate(x, y);
    rotate(a + PI / 2);
    ellipse(0, 0, s * 0.55, s);
    pop();
  }
  fill(45, 90, 100, 95);
  circle(0, 0, 14 + 4 * sin(t * 3));
}