coffeeRings
rough draft of coffee rings - click to stain
function setup() {
createCanvas(windowWidth, windowHeight);
noStroke();
angleMode(DEGREES);
background(250);
}
function draw() {
translate(width / 2, height / 2);
coffeeRing();
noLoop();
}
function coffeeRing() {
b = int(random(0, 4));
for (let i = 0; i < b; i++) {
d = random(0, 360);
r = (150, 210);
s = random(2, 45);
c = 255 * abs(sin(d));
fill(74 + c / 2, 53 + c / 2, 40 + c / 2, 200);
circle(r * sin(d), r * cos(d), s);
for (let j = 0; j < 90; j++) {
push();
translate(
r * sin(d) + random(-s / 2, s / 2),
r * cos(d) + random(-s / 2, s / 2)
);
rotate(random(0, 90));
ellipse(0, 0, random(0, s / 2), random(2, s / 2));
pop();
}
}
p = random(0, 5);
for (let i = 0; i < 360; i += 0.1) {
c = 150 * abs(sin(i));
fill(74 + c, 53 + c, 40 + c, 50);
circle(200 * sin(i), 200 * cos(i), p + (random(0, 0.5) * c) / 7);
circle(200 * sin(i), 200 * cos(i), p + (random(0, 0.5) * c) / 7);
fill(255);
}
g = random(0, 360);
h = random(g, 360);
for (let i = g; i < h; i += 0.1) {
c = 255 * abs(sin(i));
fill(74 + c, 53 + c, 40 + c, 50);
circle(190 * sin(i), 189 * cos(i), 2 + p + random(0, 0.1));
}
g = random(0, 360);
h = random(g, 360);
for (let i = g; i < h; i += 0.1) {
c = 255 * abs(sin(i));
fill(74 + c, 53 + c, 40 + c, 50);
circle(203 * sin(i), 203 * cos(i), 2 + p + random(0, 0.1));
}
}
function mousePressed() {
background(250, 250, 250, 50);
push();
translate(mouseX - width / 2, mouseY - height / 2);
coffeeRing();
pop();
}