var x1 = 0, y1 = 0, x2 = 400, y2 = 400;
function setup() {
createCanvas(400, 400);
background(0);
frameRate (5);
}
function draw() {
stroke(150, 250, 200)
line(x1,y1,x2,y2)
y1 = y1+ 5;
y2 = y2 - 5;//change the y2 with each loop
slope = (y2-y1)/(x2-x1);
strSlope = str(round(slope,1));
string = join(['Slope = ',strSlope ],'');//create the string to print;
fill(255);
rect(180,380,100,400);//make the rectangle (x,y,width,height)
stroke(0);//set the text color to black
fill(0);//set the text fill to black
text(string,200,395);//print the text
if(y1>400){
noLoop();
}
}