xxxxxxxxxx
45
// Connie Hu - Week 5 - Regerative Art
// Sources used
// https://www.youtube.com/channel/UCvjgXvBlbQiydffZU7m1_aw (Daniel Shiffman - The Coding Train)
let frog;
let angle = 0;
let slider;
function setup() {
createCanvas(400, 400);
frogs = loadImage('frog.png');
slider = createSlider(0, TWO_PI, PI / 4, 0.01);
}
function draw() {
background(145, 156, 255);
angle = slider.value();
stroke(255);
strokeWeight(5);
translate(200, height);
branch(150);
}
// branches function that will control the branches and frogs
function branch(h) {
h *= 0.65;
if (h > 6) {
push();
rotate(angle);
line(0, 0, 0, -h);
translate(0, -h);
branch(h);
pop();
push();
rotate(-angle);
line(0, 0, 0, -h);
translate(0, -h);
branch(h);
pop();
image(frogs, 0, 0, 30, 30);
}
}