The Cohen-Sutherland Line Clipping Algorithm

This page should display your solution of the Cohen-Sutherland line-clipping algorithm.
The gray square represents the viewport against which we are clipping. The border drawn below is considered to be INSIDE the viewport.

Note that this requires a Browser which supports Java 1.1 or higher. This is the default on Athena.

Instructions: Drag your mouse about the view area with one of the mouse buttons pressed.

- Left mouse button: Drag out a line and your code is run when you release the mouse button. Your line is drawn along with the correct solution. Pixels in which the correct solution and your solution overlap are drawn in green. If you see red (the correct solution) or black (your solution) you've done something wrong.
- Middle mouse button: Drag out a line interactively, drawing your line as well as the correct solution. Same color rules as above.
- Right mouse button: Drag out a line interactively, using only your code. The line is drawn in black.

How can you not be running a Java-enabled browser in this day and age?