2 min read

just enough for beauty

just enough for beauty
let cRng = [];
function setup() {
  //this canvas
  createCanvas(windowWidth * 0.8, windowHeight * 0.7); 
}
function draw() {
  //of time
  t = -0.2 + abs(sin(frameCount / 600)); 
  //takes on skies
  ground( 0,height / 2,t * 100,t * 110,t * 150,t * 180,t * 200,t * 220,random(15, 20));
  //and soaks in the earth
  ground(height / 2,height,t * 10,t * 20,t * 10,t * 50,t * 10,t * 20,random(15, 20));
}

function ground(h1, h2, r1, r2, g1, g2, b1, b2, inc) {
  //with ever changing palettes
  for(let i = 0;i<9;i++){
    cRng[i] = createVector(random(width), random(height), random(20, 80));
  }
  //stretched wide
  for (let i = -20; i < width + 20; i += inc) {
    // and stretched tall
    for (let j = h1; j < h2; j += inc) {
      //and then painted 
      for (let k = 0; k < cRng.length; k++) {
        //with conditional pigments
        if (
          i > cRng[k].x && i < cRng[k].x + random(100, 120) && j > cRng[k].y && j < cRng[k].y + cRng[k].z + random(10, 30)) {
          c = color(c1[k][0] + random(r1, r2),
c1[k][1] + random(g1, g2),c1[k][2] + random(b1, b2),
random(1, 3));
        } 
        //with chaotic pigments
        else {
          tmp = int(random(0, c1.length - 1));
          c = color(c1[tmp][0] + random(r1, r2),c1[tmp][1] + random(g1, g2),c1[tmp][2] + random(b1, b2),random(1, 3));
        }
        //with enlightment
        if (dist(i, j, width / 2, height / 2) < (width / 4) * sin(t) &&!mouseIsPressed) { 
          c = color(c1[tmp][0] + 2.2 * random(r1, r2),c1[tmp][1] + 1.5 * random(g1, g2),c1[tmp][2] + 1.5 * random(b1, b2),random(0, 2));
        }
        //and with intent
        if (dist(i, j, mouseX, mouseY) < 10 + (width / 4) * sin(t) &&mouseIsPressed) {
          c = color(c1[tmp][0] + 1.5 * random(r1, r2),c1[tmp][1] + 1.5 * random(g1, g2),c1[tmp][2] + 1.5 * random(b1, b2),random(1, 3));
        }
        stroke(c);
        fill(c);
        //to obscure
        strokeWeight(random(2, 30));
        //just enough for beauty
        point(i, j);  
      }
    }
  }
}

let c1 = [[18, 15, 13],[38, 41, 36],[60, 49, 34],[89, 64, 42],[108, 72, 76],[91, 86, 95],[105, 97, 73],[167, 93, 43],[155, 114, 77],[146, 137, 125]];

function windowResized() {
  setup();
}

See the Pen //just enough for beauty by Sophia (fractal kitty) (she/her) (@fractalkitty) on CodePen.

Want to become a better programmer? Join the Recurse Center!

Sophia

Mathematics educator and creative coder exploring the beauty of mathematical concepts through interactive visualizations and playful learning.

Mathematics

Education

Creative Coding