sketchDownload
var leafSize = 40;
function setup() {
createCanvas(400, 400);
background(220);
text("p5.js vers 0.9.0 test.", 10, 15);
}
function draw() {
background(111, 59, 72)
for (var x = 20; x <= 400; x += 50) {
for (var y = 20; y <= 400; y += 100) {
push();
leaf(x, y);
pop();
}
}
for (var x = 40; x <= 400; x += 50) {
for (var y = 80; y <= 400; y += 100) {
push();
secondLeaf(x, y);
pop();
}
}
noLoop();
}
function leaf(x, y) {
//decoration
noStroke();
fill(167, 80, 55)
circle(x-5, y+7, leafSize-15);
noFill();
stroke(167, 80, 55);
arc(x, y, 50, 50, PI/4, 5*PI/4);
stroke(225);
//left half
arc(x, y, leafSize, leafSize, 2*PI/3, 4*PI/3, OPEN);
//right half
translate(-20, 0);
arc(x, y, leafSize, leafSize, 5*PI/3, PI/3, OPEN);
//stem
translate(10, 0);
triangle(x-2, y+30, x, y-5, x+2, y+30);
line(x-5, y-5, x, y);
line(x, y, x+5, y-5);
line(x-5, y+5, x, y+10);
line(x, y+10, x+5, y+5);
}
function secondLeaf(x, y) {
//decoration
noStroke();
fill(207, 106, 39)
circle(x, y-8, leafSize/2);
noFill();
stroke(207, 106, 39);
arc(x, y, 50, 50, 5*PI/4, PI/4);
stroke(225);
//left half
arc(x, y, leafSize/2, leafSize/2, 2*PI/3, 11*PI/6, OPEN);
arc(x-13, y-13, leafSize/2, leafSize/2, PI/6, 2*PI/3, OPEN);
//right half
arc(x-10, y, leafSize/2, leafSize/2, 7*PI/6, PI/3, OPEN);
arc(x+3, y-13, leafSize/2, leafSize/2, PI/3, 5*PI/6, OPEN);
//stem
translate(-5, 0);
line(x, y, x, y-20);
}
I got the inspiration for my wallpaper from the fall season and leaves floating in the air.