This is a little P5.js drawing that generates a linear equation from 2 known points. The sliders at the bottom modify the X and Y values for each point. A line is formed between the 2 points. The linear equation is available in the top left corner of the canvas.

Spoiler alert: It does not work when X1 == X2 because we cannot divide by zero when calculating the slope, m.

Click on the link below and try the code yourself.

p5.js Web Editor
A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.