fractalkitty looking for math? fractalkitty.com

100 days of code

cactusClicking

#random#interactive#plants

drawCactus

function setup(){
  createCanvas(windowWidth,windowHeight);
  background(125, 223, 245);
 
}
function draw(){
  
  translate(width/2,height/2)
  noLoop()
}

function drawCactus(x,y){
  fill(117+random(30), 161+random(50), 85+random(30));
  a=random(10,width/4-y/3);
  b=random(50,height/2-y);
  ellipse(x,y-b/1.5,a,b);
  fill(201+random(-50,50), 144+random(-30,30), 28+random(-40,40))
  rect(x-a/2,y-b/3,a,b/3)
  print(x,y)
}

function mousePressed(){
  drawCactus(mouseX-width/2,mouseY-height/2);
}

function keyPressed() {
  if (keyCode === 32) {
    background(125, 223, 245);
  } 
}