xxxxxxxxxx
150
let doughnut1;
let doughnutSize;
let holeSize;
let frosting;
let scribble;
let sprinkleColours = ["#F2AEC1", "#F2274C", "#04B2D9", "#04BF55" ,"#F2B705"];
let messageText = [
"HOLY\nSPRINKLES",
"GIMME\nA\nRING",
"HOLE\nLOTTA\nLOVE",
"DOUGHNUT\nGIVE\nUP",
"YOU\nARE\nSWEET",
];
let myFont;
function preload() {
myFont = loadFont("fonts/PostersItalicPersonalUseBoldItalic-ALqx6.ttf");
}
function setup() {
createCanvas(400, 400, SVG);
frameRate(1);
//createLoop({duration:10, gif:true})
scribble = new Scribble();
}
function draw() {
background(255);
doughnut1 = new Doughnut();
doughnut1.show();
noLoop();
}
function mouseClicked() {
redraw();
}
class Doughnut {
constructor() {
doughnutSize = random(140, 250);
holeSize = random(30, 100);
frosting = random(1, 4);
}
show() {
noStroke();
rectMode(CORNERS);
scribble.bowing = 1;
scribble.roughness = 1;
//doughnut
fill("pink");
scribble.bowing = 1;
scribble.roughness = 1;
scribble.scribbleEllipse(
width / 2,
height / 2,
doughnutSize,
doughnutSize
);
//frosting
scribble.bowing = 2;
scribble.roughness = 3;
fill("lightblue");
scribble.scribbleEllipse(
width / 2,
height / 2,
doughnutSize-20,
doughnutSize-20
);
//sprinkles
scribble.bowing = 1;
scribble.roughness = 0.5;
strokeWeight(3);
stroke(255);
for (let i = width / 2 - doughnutSize / 2+15; i < width / 2 + doughnutSize / 2-15; i = i + 20) {
for (let j = height / 2 - doughnutSize / 2+20; j < height / 2 + doughnutSize / 2; j = j +20) {
if(i == width / 2 + doughnutSize / 2-20){
i = 0
j = j+20;
}
//stroke(sprinkleColours[floor(random(sprinkleColours.length))]);
scribble.scribbleLine(
i + random(0,20),
j - random(0,20),
i + random(3,10),
j - random(2,5)
);
}
}
// inner frosting mask
scribble.bowing = 2;
scribble.roughness = 3;
noStroke();
fill("pink");
scribble.scribbleEllipse(
width / 2,
height / 2,
holeSize+20,
holeSize+20
);
//hole
fill(255);
scribble.bowing = 1;
scribble.roughness = 1;
scribble.scribbleEllipse(
width / 2,
height / 2,
holeSize,
holeSize
);
textSize(holeSize *0.15);
noStroke();
textFont(myFont);
fill("lightblue");
textStyle(BOLD);
textAlign(CENTER, CENTER);
text(
random(messageText),
width / 2,
height / 2
);
}
}
// check for keyboard events
function keyPressed() {
switch (key) {
// type [F1] to hide / show the GUI
case "s":
save();
break;
}
}