This is a simple Example of line clipping : the display window is the canvas and also the default clipping rectangle, thus all line segments inside the canvas are drawn.
The red box is the clipping rectangle we will use later, and the dotted line is the extension of the four edges of the clipping rectangle.