Question: In the draw line function implement the gentle positive slope, gentle negative slope, steep positive slope, steep negative slope, horizontal, vertical, diagonal, polygon drawn with

In the draw line function implement the gentle positive slope, gentle negative slope, steep positive slope, steep negative slope, horizontal, vertical, diagonal, polygon drawn with multiple calls to draw line in C++.

void Rasterizer:: drawLine (int x0, int y0, int x1, int y1){

Using the midpoint line algorithm

Add the implementation using setPixel() method

param x0 x coord of first endpoint

param y0 y coord of first endpoint

param x1 x coord of second endpoint

param y1 y coord of second endpoint

}

Our in-class discussion of the midpoint line algorithm covered the case where the line segment had a small positive slope (0 < m < 1); your implementation must also handle the other three cases (large positive slope, small negative slope, and large negative slope). Also, remember that our discussion assumed that the line was being drawn from left to right (i.e., that x0 was less than x1); you are not guaranteed that this will be the case, so you'll need to remember to check the incoming coordinates and swap the vertices if necessary.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!