I am trying to implement scan line algorithm in order to fill in drawn shape with color in program qt creator where I use c++. I am particularly stuck on part 2. Can someone give me advice how to deal with this?
//parameter vector of segments, after I draw shape on my screen, each segment that has been connected with line is stored in this vector.
void MyProgram::drawScanLine(std::vector<Segment> p) {
double minY = p[0].y;
double maxY = p[0].y;
for(int i=0;i<p.size();i++) {
if(p[i].y < minY) {
minY = p[i].y;
}
if(p[i].y> maxY) {
maxY = p[i].y;
}
}
//x[]
//find the intersection from the horizontal level of y
//sort the array/vector (x[])
//I have a method that fills every pixel with color.
std::cout<<"MIN: "<<minY<<"MAX: "<<maxY<<std::endl;
for(int y=minY;y<=maxY;y++) {
std::cout<<"Test"<<std::endl;
}
}