Skip to content

Flower 1

An experiment in drawing gradients with shapes.

A pink flower against a skyblue background with shifting number (9-10) of spinning petals

function setup() {
  createCanvas(400, 400);
}

function draw() {
  background(150, 240, 240);
  
  noFill()
  stroke(100, 230, 130)
  strokeWeight(20)
  curve(120+sin(frameCount * 0.2)*30, 600, 200, 450, 200, 200, 50, 50)
  push()
  translate(200, 200)
  rotate(-frameCount * 0.003)
  noStroke()
  let c = 9.5 - cos(frameCount * 0.00165)*0.5
  fill(250, 220, 50)
  circle(0, 0, 20)
  for (let h = 0; h < c; h ++) {
    push()
    beginClip({invert: true})
    rotate(PI*2/c * h)
    ellipse(-16, 90, 100, 180)
    rotate(-PI*2/c)
    endClip()
    for (let i = 0; i < 50; i ++) {
      fill(lerpColor(color(255, 130, 160), color(250, 220, 250), i / 50))
      ellipse(i*sin(frameCount * 0.1)*0.3 - 16, 90-i*(0.7 + sin(frameCount * 0.34)*0.2), 100-2*i, 180-i*2)
    }
    pop()
  }
  pop()
}

(Originally seen at https://editor.p5js.org/bojidar-bg/sketches/so-shUH74)

Experiments tagged p5 (7/85)

Experiments on this site (7/85)