xxxxxxxxxx
69
let cX, cY, size, tW, tH;
function setup() {
createCanvas(400, 400);
background('white');
}
function draw() {
cX = width/2;
cY = height/2;
size = width*0.4;
tW = size/2;
tH = size/3.5;
strokeWeight(5);
stroke(51);
ellipse(cX, height/3, size, size)
triangle(cX-tW, cY-tH, cX+tW, cY-tH, cX, cY*1.5);
drawAdditives();
noLoop();
}
function drawAdditives() {
let additives = [drawConeCurve, drawTopping, drawMarshmallow, drawChip, drawSwirl];
for (let i = 0; i < additives.length; i++) {
if (random(0,1) < 0.5) {
push();
strokeWeight(4);
stroke(51);
fill(51);
textFont('Helvetica');
ellipseMode(CENTER);
rectMode(CENTER);
textAlign(CENTER);
textSize(260);
additives[i].call();
pop();
}
}
}
function mousePressed() {
clear();
draw();
}
function drawConeCurve() {
line(160, 225, 257, 195);
}
function drawTopping() {
arc(cX, height/3, size, size, PI, 0, CHORD);
}
function drawMarshmallow() {
square(cX+ 40, height/7, size/3, 20, 15, 10, 5);
}
function drawChip() {
point(cX, cY/2.5);
}
function drawSwirl() {
text('~', cX-5, 191);
}