Click 'Run' to go.
Well, it's actually a line segment, and it's drawn between two endpoints, (x1, y1) and (x2, y2).
Try the demo below and experiment with changing the values of the coordinates. There is more information below.
Perhaps this is not the best name for this command. Really, the command line draws a line segment, since the graphic has endpoints. A line, as usually encountered in geometry, goes on to infinity. It has no endpoints. However, many computer languages use this shorthand name for the command, and we will do also here.
We will call the first endpoint (x1, y1), and we will call the second endpoint (x2, y2). Here's a picture of a line segment drawn between two endpoints:
In our demo below the command to draw a line segment is named line. This command is followed by four expressions separated by commas. The expressions here are simple numbers. The first two numbers represent the coordinates for one endpoint, (x1, y1). The next two numbers are the coordinates for the other endpoint, (x2, y2).
Here's a simple flowchart for this program:
In an imaginary computer language this could look like the following:
line(0, 0, 5, 7);
Suggested next article:
An article related to this demo: