Instructions: There are two ways to draw a line. The mouse way entails clicking at a point and then dragging the mouse with the button still down and then releasing at the desired endpoint. The keyboard way requires the user to press the 's' key to select a start point for the line and then either pressing or pressing and holding the 'e' key to select the end point of the line. By holding 'e' down, the user can see the line rubber-banding before he selects the final end point by releasing the key.

One problem I faced while working on this homework assignment was lines not properly displaying when switching between mouse input and keyboard input after having placed a line. I realized that I had set the startline boolean value in the wrong spot of the code and that I was missing one after doing a mouse line. I also had trouble trying to figure out the algorithm for lines outside of -1 to 1. I initially had tried to figure the algorithm out without googling it but I succumbed to the pressure of convenience and then worked it out from there.

My favorite part of working with the program was making rubber-banding work with the keyboard. It took me a little to figure out the trick of redrawing but the result is nice.

My code

dda.cpp

Screencaps!

hori vert slope1 slope-1

My Homework

More updates coming soon, until then, enjoy this No Face feels gif.

noface