xxxxxxxxxx
78
function setup() {
createCanvas(400, 400);
frameRate(15);
angleMode(RADIANS);
}
function draw() {
background(40);
push();
translate(width/2, height/2);
strokeWeight(2);
let r = 150
fill(100);
recCircle(width/2, height/2, 10);
circle(0,0,r*2);
stroke(40);
fill(40);
radialSpray(r);
drawEye(65, -30, 90);
drawEye(-65, -30, 90);
pop();
}
function radialSpray(rad) {
for(let a = 0; a < TAU; a += 0.025) {
for(let r = 0; r < rad; r+=3) {
if(random() < 0.2) {
point(polarToRect(r, a));
}
}
}
}
function drawEye(x, y, width) {
x = x-(width/2); //centering
push();
fill(40);
stroke(100);
beginShape();
vertex(x, y);
let dy1, dx1, dy2, dx2;
dy1 = dx1 = dy2 = (width/2.66);
dx2 = width - dx1;
dy2 = dy1 = dx1 * cos(frameCount / 5);
bezierVertex(x+dx1, y-dy1, x+dx2, y-dy2, x+width, y);
bezierVertex(x+dx2, y+dy1, x+dx1, y+dy2, x, y);
endShape();
pop()
}
function recCircle(x, y, r){
if(r < 300-10){
circle(x, y, r);
recCircle(x - 15, y - 15, r + 20);
}
}
function polarToRect(r, ang){
let x = r * cos(ang);
let y = r * sin(ang);
let v = createVector(x, y);
return v;
}