// cookie monster pattern
let electricBlue = '#0F98DC'
let persianBlue = '#0061AC'
let darkCerulean = '#174883'
let brightGrey = '#EBEBEB'
let smokeyBlack = '#0C0C0C'
let chocoChip = '#936c48'
let x,y,vx,vy
function setup() {
createCanvas(800, 800);
x = width/2
y = height/2
vx = random(-1,1)
vy = random(-1,1)
background(brightGrey)
}
function draw() {
fill(255,50)
rect(0,0,width,height)
let d = width/2 // diameter
push()
scale(0.75+sin(frameCount*0.01)*0.25)
translate(x,y)
rotate(frameCount*0.02)
for (a = 0; a < TWO_PI; a+=PI/8){
push()
rotate(a)
translate(d*sin(frameCount*0.01)*0.75+d/2,0)
scale(0.25)
cookie(d)
push()
rotate(frameCount*0.01)
translate(d,0)
scale(0.5)
cookieMonster(d)
pop()
pop()
}
cookieMonster(d)
pop()
x+= vx
y+= vy
if (x + d/4 > width){
vx = -vx
}
if (x - d/4 < 0){
vx = -vx
}
if (y + d/4 > height){
vy = -vy
}
if (y - d/4 < 0){
vy = -vy
}
}
function cookie(d){
push()
stroke(smokeyBlack)
strokeWeight(10)
fill(chocoChip)
circle(0,0,d)
fill(smokeyBlack)
scale(0.25)
square(0,0,d,d)
pop()
}
function cookieMonster(d){
stroke(smokeyBlack)
strokeWeight(5)
fill(persianBlue)
circle(0,0,d)
fill(255)
circle(-d/6,-d/3,d/3)
circle(d/6,-d/3,d/3)
fill(0)
push()
translate(-d/6,-d/3)
rotate(frameCount*0.05)
circle(10,0,d/8)
pop()
circle(d/6,-d/3,d/8)
arc(0, 0, d/2, d/2, 0, PI, PIE); // white ellipse with top right quarter missing with black outline around the shape.
}