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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started