CMPS-3480 Computer Graphics
Lab-2

Elements of the lab:

Step 1:
We will do some coding together on Zoom.

Do your work in your Odin 3480/2 folder.

Get the starting code at:
   /home/fac/gordon/p/3480/code/lab2/lab2.cpp

cp /home/fac/gordon/p/3480/code/lab2/* .

We will add the following features together...

   1. connecting points with lines

   2. adding more points (and lines)

   3. add the Bresenham's algorithm to draw lines

   4. adding anchors to see points better

   5. grab a point with the mouse and move it
      rubber-band lines

Our program will look something like this


With rigid lines...


Bresenham's line algorithm:

Homework...

Bresenham line algorithm

NOTICE:
Do not use x11.drawLine() inside your Bresenham function.
Only x11.drawPoint() is allowed.

Add a comment showing the URL of where you found your code.

1. Use the internet or a textbook to find an implementation
   of Bresenham's line algorithm.

   Add it to your program.

2. On key-press 'L', make your program switch line drawing type
   between Bresenham and the X11 line function.


Closest point to mouse

1. Whenever the mouse is moved, look for the closest point to the mouse cursor.

2. If the distance is a short distance, draw a red box around the close point.

   Remember, all drawing is done from render().
   Set a flag to draw the red box.

      g.redbox = -1   No points have a red box.
      g.redbox =  3   g.pt[3] needs a red box around it.