xxxxxxxxxx
157
let r, g, b;
let t = 0;
let move_sun_dir = 1;
let move_sea_dir = 1;
let sea_level = 30;
function setup() {
createCanvas(400, 400);
r = random(255)
g = random(255)
b = random(255);
}
function draw() {
background(135, 206, 235);
//Curve for Sun Movement
x1 = 0
x2 = 100
x3 = 300
x4 = 400
y1 = 150
y2 = 0
y3 = 0
y4 = 150
noFill()
let x = bezierPoint(x1, x2, x3, x4, t)
let y = bezierPoint(y1, y2, y3, y4, t)
t += 0.001 * move_sun_dir //regulating the speed of the sun
if (t > 1 || t < 0) {
move_sun_dir *= -1
} //not letting the sun to go away from the screen
//Sun
fill(255,255,112)
noStroke()
circle(x, y, 50)
//Beach
fill(255, 234, 200)
noStroke()
rect(200, 400, 400, 200)
//Sea
fill(0, 105, 148)
noStroke()
rectMode(CORNER)
rect(0, 280, 400, sea_level)
sea_level += 0.05 * move_sea_dir //regulating the speed of the sea level
if (sea_level > 40) {
move_sea_dir = -1;
}
else if (sea_level < 30) {
move_sea_dir = 1;
} // keeping the sea level between the rectangle size values
// Head
fill(255,205,148)
noStroke()
ellipse(200, 200, 120, 150);
// Eyes
fill('white')
circle(175, 185, 15);
circle(225, 185, 15);
//Eyeballs
fill('black')
circle(175, 185, 5);
circle(225, 185, 5);
//Mouth
fill('white')
stroke('rgb(255,189,201)')
strokeWeight(4)
arc(200, 235, 35, 25, 0, PI, CHORD);
//Nose
fill(224,172,105)
noStroke()
ellipse(200, 210, 10, 20);
//Ears
fill(255,205,148)
ellipse(140, 190, 20, 30);
ellipse(260, 190, 20, 30);
//Side Hair
fill('black')
quad(145, 145, 165, 150, 160, 185, 145, 180);
quad(248, 140, 235, 145, 240, 185, 257, 180);
//Top Hair
fill('black')
ellipse(width / 2 - 5, 135, 110, 50);
//Eyebrows
noFill()
stroke('black')
arc(175, 180, 16, 16, PI + 0.6, TWO_PI - 0.5)
arc(225, 180, 16, 16, PI + 0.6, TWO_PI - 0.5)
//Tank top and Torso
noStroke()
fill(255,205,148)
ellipse(150, 370, 100, 200)
ellipse(250, 370, 100, 200);
rectMode(CENTER)
fill(r, g, b)
rect(200, 370, 115, 200);
stroke(255, 234, 200)
strokeWeight(5)
triangle(137, 400, 140, 325, 140, 400)
triangle(260, 400, 260, 325, 263, 400)
//Neck
noStroke()
fill(255,205,148)
arc(200, 270, 50, 50, 0, PI, CHORD);
//SunGlasses
fill(0, 0, 0, 100)
stroke('black')
strokeWeight(0.2)
arc(175, 178, 22, 37, 0, PI, CHORD)
arc(225, 178, 22, 37, 0, PI, CHORD)
strokeWeight(2)
line(143, 175, 164, 185)
line(236, 185, 257, 175)
line(186, 185, 214, 185)
}
// Changing color of the tank top
function mouseClicked() {
r = random(255)
g = random(255)
b = random(255)
}