I have a Ball.

Xpos = 10
Ypos = 10
function draw()
    Xspeed = 5
    Yspeed = 5
    Xpos = Xpos + Xspeed
    Ypos = Ypos + Yspeed
    ellipse(Xpos, Ypos, 100)

If I have a line, that line could be anywhere with any slope, how would I make the ball bounce off of this line?
I have consulted my friends and they all are stumped, Help!

I did use a similar method until I realized I may have to reflect off of lines that could be at any angle. The article only covers walls, which are verticle ans horizontle.

or without physics (harder to code)

thank you.