-
Notifications
You must be signed in to change notification settings - Fork 4
final mattgpt sketch
Daniel Shiffman edited this page Apr 15, 2024
·
1 revision
// Adding at the top
let birds = [
{ x: 250, y: 150 },
{ x: 350, y: 100 },
];
function setup() {
createCanvas(600, 300);
// noLoop(); // DS fix
}
function draw() {
background(255);
stroke(0);
push(); // DS FIX
translate(300, height);
branch(100);
pop(); // DS FIX
// Drawing birds
birds.forEach((bird) => {
push();
translate(bird.x, bird.y);
scale(0.8);
bird.x += random(-2, 2); // Birds fidgeting
bird.y -= 2; // Birds starting to fly away
drawBird();
pop();
});
}
function branch(len) {
line(0, 0, 0, -len);
translate(0, -len);
if (len > 4) {
push();
rotate(PI / 4);
branch(len * 0.67);
pop();
push();
rotate(-PI / 4);
branch(len * 0.67);
pop();
if (len > 20) {
push();
rotate(PI / 6);
branch(len * 0.5);
pop();
push();
rotate(-PI / 6);
branch(len * 0.5);
pop();
}
}
}
function drawBird() {
fill(0); // DS FIX
ellipse(0, 0, 20, 15); // body
triangle(-10, 0, -20, -5, -20, 5); // tail
ellipse(-5, -5, 5, 5); // head
}