## Bresenham’s Line Drawing Algorithm

- Read two end points (x1,y1) and (x2,y2) store initial point (x1,y1)
- Load (x1,y1) into frame buffer and plot it.
- calculate decision perimeter P it as follows:
- p=2 Δx-Δy
- where Δx=x2-x1 and Δy=y2-y1

- if p<0 then the next point to plot is (x,y+1) and p=p Δx+2 otherwise the next point is (x+1,y+1) and p=p+2Δx+2Δy
- Repeat step 4 Δy times

now we have

x1=0,y1=0,x2=3 and y2=8

Δx=x2-x1=3

Δy=y2-y1=-2

p= 2Δx- Δy=-2

Now the loop steps can be talculated as:

## Scan-Line Polygon Fill Algorithm

The Scan-Line Polygon Fill Algorithm is very efficient and cheaper alternative it is also known as Alternative fill method. In this method scan lines are used for filling the polygon.It’s wokig effectively with the self intersecting polygon

In this we have to use the smallest rectangle which fits the polygon which needs the rectangle to be created from the lower left corner to the upper right corner co-ordinate of the polygon for generating the scan line we have to consider the largest by value and move towards the smallest by value and draw a horizontal line among all possible values of y since we are using scan line to fill the polygon this method is known as scan line fill method