float position;
float speed = -5;
float radious = 150;
float surface = 400;
void setup(){
size(500, 500);
frameRate(30);
smooth();
stroke(128);
strokeWeight(5);
position = radious;
}
void draw(){
background(255);
float startAng = PI + asin(position / radious);
float stopAng = TWO_PI -asin(position / radious);
beginShape();
curveVertex(0, surface);
curveVertex(0, surface);
curveVertex(width / 2 - radious, surface);
float angStep = (stopAng - startAng) / 16;
for(int i = 1; i < 16; i++){
float ang = startAng + angStep * i;
PVector arcPoint = new PVector(width / 2 + radious * cos(ang), surface + position + radious * sin(ang));
curveVertex(arcPoint.x, arcPoint.y);
}
curveVertex(width / 2 + radious, surface);
curveVertex(width, surface);
curveVertex(width, surface);
endShape();
position += speed;
if(position <= -radious || radious <= position){
speed *= -1;
}
}