Skip to content

Prismatic gem

A white rhomb pulsing with many different colors

let r

function setup() {
  createCanvas(300, 300);
  r = random(13200)
}

function draw() {
  background(130);
  let x
  function n(y) {
    x += 10
    return noise(x, y + x/100, 2+millis() / 2000) - 0.5
  }
  for (let j = 0; j < 2; j ++) {
    x = r
    for (let i = 40; i >= 0; i --) {
      if (j == 1) {
        fill(255, 20 + n(i) * 20)
        noStroke()
        x += 30
      } else {
        noFill()
        stroke(
          130 + n(i) * 200,
          130 + n(i) * 200,
          130 + n(i) * 200
        )
        strokeWeight(4.5 + n(i) * 3)
      }
      beginShape()
      vertex(150 + n(i*0.2) * 25, 50 + n(i*0.2) * 50)
      vertex(250 + n(i*0.2) * 50, 150 + n(i*0.2) * 25)
      vertex(150 + n(i*0.2) * 25, 250 + n(i*0.2) * 50)
      vertex(50 + n(i*0.2) * 50, 150 + n(i*0.2) * 25)
      endShape(CLOSE)
    }
  }
}

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

Experiments tagged p5 (37/85)

Experiments on this site (37/85)