# Scan Line Algorithm For Polygon Filling

#### fasihxkhatib

##### Distinguished
Please explain scan line algorithm for polygon filling in simple terms.
Thanks

#### theDanijel

##### Distinguished
It's like printing in an ink jet printer. You draw one colour line from left edge of the polygon to the right edge, then repeat the same thing from top of the polygon to the botomn.

#### fasihxkhatib

##### Distinguished
And can u pls explain the program?

#### theDanijel

##### Distinguished
Homework? If you have the algorithm it should be self explaning.
it should go something like this:
foreach poligon
{
determine top and botomn
define current point and set it to top
while current point is not botomn
{
calculate left and right edge of polygon on the current point's height
draw horizontal line from left to right
set current point to next moveing to botomn (when current point is the same as botomn the loop will end)
}
}

#### fasihxkhatib

##### Distinguished
I get the algorithm. Algorithm is far from program.
I know the algorithm, need explanation for program.

#### theDanijel

##### Distinguished
What program?
An implementation of this algoritm or a whole program? You need a whole program?

#### fasihxkhatib

##### Distinguished
I have the CODE, entire. I just want an explanation of whats going on

#### theDanijel

##### Distinguished
Then post the code. How can anyone explain what he doesn't see?

#### fasihxkhatib

##### Distinguished
i thought you knew it by heart

#### fasihxkhatib

##### Distinguished
It is quite a long code in C. will post it as soon as Im done typing it.