fractalkitty looking for math? fractalkitty.com

codepen challenges

satin

#random#trig#interactive#codepen-challenge

Georgia O'Keeffe is one of my favorite artists. She inspires me.

outer

function setup() {
  cnv = createCanvas(windowHeight * 0.5, windowHeight * 0.9);
  background(255);
  fill(0);
  noLoop();
}
function draw() {
  translate(width / 2, 0);
  push();
  scale(0.02, random(1,1.3));
  outer(
    height / 1.5,
    random(60, 100),
    random(60, 100),
    random(10, 40),
    random(20, 90),
    random(10, 90),
    random(0.5,2)
  );
  pop();
  push();
  scale(random(0.03,0.06), random(1,1.3));
  outer(
    height / 1.5,
    random(10, 40),
    random(10, 40),
    random(10, 40),
    random(20, 90),
    random(10, 90),
    random(0.5,2)
  );
  pop();
  push();
  scale(random(0.1,0.25), random(1,1.3));
  outer(
    height / 1.5,
    random(190, 220),
    random(190, 220),
    random(170, 210),
    random(20, 90),
    random(10, 40),
    random(0.5,2)
  );
  pop();

  push();
  scale(0.3, 1);
  outer(
    height / 1.5,
    random(20, 70),
    random(40, 80),
    random(60, 100),
    random(10, 40),
    random(10, 40),
    random(0.5,2)
  );
  pop();
  push();
  translate(0, height * 1.5);
  scale(0.7, -1);
  outer(
    height / 1.5,
    random(200, 220),
    random(100, 150),
    random(70, 110),
    random(20, 90),
    random(10, 60),
    random(0.5,2)
  );
  pop();

  outer(
    height / 1.5,
    random(170, 210),
    random(120, 170),
    random(20, 70),
    random(20, 60),
    random(10, 40),
    random(1,3)
  );
  push();
  scale(random(2, 2.4), random(1,1.3));
  outer(
    height / 1.5,
    random(90, 110),
    random(120, 160),
    random(120, 160),
    random(20, 60),
    random(10, 40),
    random(2,4)
  );
  pop();
  fill(255);
  rect(-width/2,0,5,height)
  rect(width/2-5,0,5,height)
  rect(-width/2,0,width,5)
  rect(-width/2,height-5,width,5)
}

function outer(a, r, g, b, m, n, f) {
  noFill();
  for (let j = 0; j < 200; j++) {
    stroke(r + j * f, g + j * f, b + j * f);
    beginShape();
    for (let i = 0; i < PI / 4; i += 0.005) {
      y = a * i + i * 2;
      x = a * i * i * sqrt(1 - i * i) + 3 * sin(i * m) * cos(i * n);
      vertex(x / 1.5 + j, y * 1.9);
    }
    endShape();
    beginShape();
    for (let i = 0; i < PI / 4; i += 0.005) {
      y = a * i + i * 2;
      x = a * i * i * sqrt(1 - i * i) - 3 * sin(i * m) * cos(i * n);
      vertex(-x / 1.5 - j, y * 1.9);
    }
    endShape();
  }

}

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

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

function keyPressed(){
  if (keyCode === 83){
    save(cnv,'satin.png')
  }
}