xxxxxxxxxx
113
//variables:
var angle = 2.0;
var offset = 300;
var scalar = 0.5;
var speed1 = 0.1;
var speed2 = 0.02;
var cheese = 0;
var topp = 0;
var cheese_amount = 250; //increase if you want more cheese
var topping_amount = 40; //increase if you want more topping
//---------------------------
function setup() {
createCanvas(600, 600);
make_dough();
}
function draw() {
spread_sauce("a little"); //change argument to "a lot"
spread_cheese();
put_topping("pepperoni"); //change argument to "veggies"
}
//--------------------------
//below are all the functions - with lots of while loops
function make_dough() {
noStroke();
fill("#ecc076");
circle(300, 300, 550);
fill("#f7e4c4");
circle(300, 300, 450);
}
function spread_sauce(amount) {
if (amount == "a lot") {
sauce_2();
} else if (amount == "a little") {
sauce_1();
}
}
function sauce_1() {
while (angle < 210) {
var x = offset + cos(angle) * scalar;
var y = offset + sin(angle) * scalar;
fill("#FF0000");
noStroke();
ellipse(x, y, 5, 5);
angle += speed1;
scalar += speed1;
}
}
function sauce_2() {
while (angle < 200) {
var x = offset + cos(angle) * scalar;
var y = offset + sin(angle) * scalar;
fill("#FF0000");
noStroke();
ellipse(x, y, 5, 5);
angle += speed2;
scalar += speed2;
}
}
function spread_cheese() {
while (cheese < cheese_amount) {//increase this number if you want more cheese!
fill(255);
let x = random(120, 460);
let y = random(140, 440);
let w = random(1, 5);
let h = random(30, 50);
rect(x, y, w, h);
let x1 = random(130, 420);
let y1 = random(130, 430);
let w1 = random(1, 5);
let h1 = random(30, 50);
rect(x1, y1, h1, w1);
cheese += 1;
}
}
function put_topping(topping) {
while(topp < topping_amount) {
if (topping == "pepperoni") {
fill("#aa4400");
stroke(0);
let x = random(150, 450);
let y = random(140, 440);
circle(x, y, 50);
topp += 1;
}
else if (topping == "veggies"){
fill("#64A90C");
stroke(0);
let x = random(150, 450);
let y = random(140, 440);
circle(x, y, 50);
topp += 1;
}
}
}