xxxxxxxxxx
409
// add drawings to make look like a bath
let s;
let offset = 10;
let bx1, bx2;
let tileSize, shadow;
let o = 200;
let ospeed = 2;
let corner1, corner2, corner3, corner4, corner5;
let rx, ry, rx2;
let canv;
function setup() {
canv = createCanvas(windowWidth, windowHeight);
console.log("windowWidth:")
pixelDensity(4);
strokeCap(ROUND);
bx1 = random(windowWidth*.25, windowWidth*.75);
bx2 = random(windowWidth*.25, windowWidth*.75);
let edge = windowWidth * .75;
rx = random(0, windowWidth * .75);
rx2 = random(0, windowWidth * .75);
console.log(windowWidth + ", " + edge + ", " + rx2)
}
function mousePressed() {
//saveCanvas(canv, 'bathub', 'png');
}
function draw() {
background(0, 255, 255);
tileSize = 46;
console.log("windowHeight: " + windowHeight);
shadow = tileSize/10;
corner1 = windowHeight/4;
corner2 = corner1 + tileSize*2;
corner3 = corner2 + tileSize*2;
corner4 = windowHeight - corner1;
corner5 = corner4 + tileSize;
byuk(0, corner1);
badak(corner1, corner2);
byuk(corner2, corner3);
if (windowHeight > 640) {
badak(corner4, corner5);
byuk(corner5, windowHeight);
s = round(frameCount/20);
if (s % 2 == 0) {
offset = 10;
} else {
offset = 0;
}
bubble(bx1 + offset, windowHeight/2, 20, 200);
bubble(bx1 + 50, (windowHeight/2 + 50) + offset, 25, 100);
bbanjjak(bx2 + offset, windowHeight/2 - offset, 10, 255);
bbanjjak(bx2 - offset, (windowHeight/2 + 100) + offset, 15, 150);
if (o > 230 || o < 150) {
ospeed *= -1;
}
o += ospeed;
}
if (windowHeight > 400) {
mirrors(o);
}
// bottom
fill(255,255,0);
stroke(0);
strokeWeight(1);
ellipse(rx2, corner2-tileSize*.67, tileSize*2, tileSize);
//ellipse(rx2, corner2-tileSize*1.35, tileSize*2.75, tileSize/2);
noStroke();
quad(rx2+tileSize * .95, corner2-tileSize/2, // bottom
rx2 - tileSize * .95, corner2-tileSize/2, // bottom
rx2 - tileSize * 1.3, corner2-tileSize*1.5,
rx2 + tileSize * 1.3, corner2-tileSize*1.5);
stroke(0);
strokeWeight(1);
line(rx2+tileSize * .95, corner2-tileSize/2,
rx2 + tileSize * 1.3, corner2-tileSize*1.5);
line(rx2 - tileSize * .95, corner2-tileSize/2,
rx2 - tileSize * 1.3, corner2-tileSize*1.5);
// rim/top
stroke(255,255,200);
fill(255,230,0);
strokeWeight(shadow*2);
ellipse(rx2, corner2-tileSize*1.5, tileSize*2.75, tileSize* .75);
// rim border
stroke(0);
strokeWeight(1);
noFill(0);
ellipse(rx2, corner2-tileSize*1.5, tileSize*2.75+ shadow*2, tileSize* .75 + shadow*2);
fill(255,255,200);
let banana = tileSize * .25;
let milk = tileSize * 1.25
quad(rx+banana/3, corner4-banana,
rx + milk - banana/3, corner4-banana,
rx + tileSize - banana/2, corner4 - tileSize+banana/2,
rx+banana*1.5, corner4-tileSize+banana/2);
quad(rx+banana/3, corner4,
rx + milk - banana/3, corner4,
rx + milk - banana, corner4 + tileSize*.75,
rx+banana, corner4+tileSize*.75);
rect(rx, corner4-tileSize*.25, milk, banana);
arc(rx+milk/2, corner4 + tileSize*.75-1, milk*.6, banana, 0, PI);
arc(rx+milk/2, corner4, milk-2, banana, 0, PI);
arc(rx+milk/2, corner4-banana, milk-2, banana, 0, PI);
stroke(255,255,200);
strokeWeight(2);
line(rx+2, corner4-tileSize*.25 + banana,
rx + milk-2, corner4-tileSize*.25 + banana);
line(rx+4, corner4-tileSize*.25,
rx + milk-4, corner4-tileSize*.25);
stroke(0);
strokeWeight(1);
fill(0,100,0);
arc(rx+milk/2, corner4 - tileSize*.85, milk*.5, banana*1.5, 0, PI);
ellipse(rx+milk/2, corner4 - tileSize*.9, milk/2, banana);
// scrubber, needs to be at the end of draw to reset shearX()
let sy = corner2 - tileSize * .8;
fill(0,255,0);
let w = tileSize * 1.25;
let h = tileSize * .5;
push();
shearX(PI/3.5);
strokeWeight(2)
rect(rx2, sy, w, h);
strokeWeight(1)
line(rx2, sy + tileSize * .15, rx2 + w, sy + tileSize * .15)
line(rx2, sy + tileSize * .2, rx2 + w, sy + tileSize * .2);
pop();
}
function shampoo(x, y) {
fill(255,200,255);
strokeWeight(1);
stroke(0);
x = x+tileSize * .5;
y = y + tileSize*1.5;
rect(x, y, tileSize*.75, tileSize * 1.5, tileSize * .2);
fill(255);
rect(x+tileSize/4,y-tileSize/8, tileSize/4, tileSize/8);
rect(x+tileSize/5,y-tileSize/5, tileSize*.6, tileSize/9);
arc(x+tileSize*.4, y-tileSize * .2, tileSize*.4, tileSize/4, PI, 0);
stroke(255,100);
strokeWeight(shadow);
line(x+tileSize*.6,y + tileSize*.15,
x + tileSize*.6, y + tileSize)
}
function mirrors(o) {
let mw = tileSize * 3;
let w = tileSize/3;
/* mirrors */
for (let x = mw; x < windowWidth; x += mw * 2) {
let y = 0;
fill(245);
strokeWeight(1);
stroke(0);
//ellipse(x, y, mw, mw);
let left = x - tileSize /2
rect(left, -tileSize/2, mw, mw, tileSize/2) ; // rounded grey
// noStroke();
fill(0, 255, 255);
rect(left, 0, mw, mw * .5); // water reflection
let tileRef = tileSize * .75;
let bottom = mw - tileRef;
let side = tileRef/2;
// horizontal
line(left + tileRef/10, bottom, left + mw - tileRef/10, bottom);
line(left, bottom - tileRef/2, left + mw, bottom - tileRef/2);
// vertical
let right = left + mw - side/2;
for (let s = left + side; s <= right; s += side) {
line(s, bottom - tileRef, s, bottom + tileRef/3);
}
// reflection
noStroke();
fill(255, o);
let rleft = left + tileRef *.25;// + tileSize;
quad(rleft, 0, // top left
rleft + tileRef, bottom + tileRef/3, // bottom left
rleft+ tileSize * 1.5, bottom + tileRef/3, // bottom right
rleft+ tileRef, 0); // top right
rleft = left + tileRef;// + tileSize;
quad(left, tileSize, // top left
rleft - tileRef/2, bottom + tileRef/3, // bottom left
rleft, bottom + tileRef/3, // bottom right
left , 0); // top right
let c = left + mw/2;
if (windowHeight > 520) {
shower(c, bottom + tileSize/2, tileSize*.25, mw*.75);
faucet(left, bottom-tileSize/2, mw, tileSize);
}
if (windowHeight > 800) {
stool(c, bottom + tileSize*2, mw);
}
if (windowHeight > 640) {
shampoo(left - mw/2, bottom);
}
}
}
function shower(x, y,w, d) {
fill(230);
strokeWeight(1);
stroke(0);
x = x-w*.5
y = y + w
rect(x,y, w, w*2)
rect(x + d,0, w, y+w*2)
strokeWeight(w);
stroke(230)
noFill();
arc(x+d/2+w/2, y+w*2, d, d, 0, PI);
strokeWeight(1);
stroke(0)
noFill();
arc(x+d/2+w/2, y+w*2, d+w, d+w, 0, PI);
arc(x+d/2+w/2, y+w*2, d-w, d-w, 0, PI);
fill(230)
rect(x + d - w*.25,-w, w*1.5, d/2+w, w/2)
stroke(255);
strokeWeight(w/2);
line(x + d + w*.67,-w,
x + d + w*.67, d/2-w*.75);
// add line for reflections!
}
function faucet(x, y, w, t) {
strokeWeight(1);
fill(200);
stroke(0)
x = x + w*.2;
w = w * .6
h = t/2
rect(x,y + t, w, h);
ellipse(x, y + t * 1.25,t/4,h);
fill(255,0,0)
ellipse(x, y + t * 1.25,t * .15,t * .15);
fill(200);
stroke(200);
strokeWeight(2);
line(x+w, y+t+2, x+w, y+t+h-2)
stroke(0);
strokeWeight(1);
arc(x+w, y + t * 1.25, t/4, h,PI + HALF_PI, HALF_PI);
arc(x + t/3, y + t * 1.25, t/4, h,PI + HALF_PI, HALF_PI);
arc(x+w - t/3, y + t * 1.25, t/4, h,PI + HALF_PI, HALF_PI);
}
function stool(x,y,w) {
// x = x *1.25;
strokeWeight(1);
w = w * .75;
fill(191, 218, 255);
stroke(0);
// ellipse(x,y + tileSize * 1.6-2,w*1.2,w/3);
let lx = x-w/2;
quad(lx,y,
lx + w, y,
lx+w+tileSize * .25, y + tileSize * 1.5,
lx-tileSize * .25, y + tileSize*1.5,
);
ellipse(x,y,w,w/3);
noStroke();
// fill(255)
// ellipse(x,y + tileSize * 1.6-2,w*1.2,w/3); // bottom solid
strokeWeight(shadow);
stroke(224, 237, 255);
ellipse(x,y+shadow/2,w-shadow,w/3); // top
stroke(0, 50);
strokeWeight(1);
ellipse(x,y,tileSize *.5,tileSize*.2); // top hole
stroke(0);
arc(x, y + tileSize*1.5, w+tileSize * .5, w * .33, 0, PI);
stroke(2);
stroke(191, 218, 255);
line(lx+w+tileSize * .25 +1, y + tileSize * 1.5,
lx-tileSize * .25-1, y + tileSize*1.5);
fill(0);
noStroke();
ellipse(x, y + tileSize * 1.8, w*.5, w * .1);
arc(x, y + tileSize*1.8, w*.5, w * .4, PI, 0);
//rect(x,y,w,w);
}
function byuk(s,e) {
for (let y = s; y < e; y = y + tileSize) {
for (let x = 0; x < windowWidth; x = x + tileSize) {
tile(x, y, tileSize, shadow, 255, 0);
}
}
}
function badak(s, e) {
for (let y = s; y < e; y = y + tileSize/2) {
for (let x = 0; x < windowWidth + tileSize; x = x + tileSize) {
floortile(x, y, tileSize, shadow, 255, 0);
}
}
}
function floortile(x,y, w, s, c, o) {
strokeWeight(1);
stroke(o);
fill(c);
quad(x-w, y, x, y, x+w, y+w/2, x, y+w/2)
strokeWeight(s)
stroke(200, 100);
line(x, y + w/2 - s, x + w - s, y + w/2 - s);
}
function tile(x,y, w, s, c, o) {
strokeWeight(1);
stroke(o);
fill(c);
rect(x, y, w, w);
strokeWeight(s);
stroke(200, 100);
line(x + w - s, y + s, x + w - s, y + w - s);
line(x + s, y + w - s, x + w - s, y + w - s);
}
function bubble(x, y, d, o) {
strokeWeight(1);
stroke(255);
fill(255, o);
ellipse(x, y, d, d);
}
function bbanjjak(x, y, l, o) {
strokeWeight(4);
stroke(255, o);
line(x - l, y, x + l, y);
line(x, y - l, x, y + l);
}