Thursday, May 28, 2009

BRENHAM’S CIRCLE DRAWING ALGORITHM

1. Read the center xc, yc and radius r

2. x = xc

3. y=r

4. plot points( )

5. p = 1 - radius

6. while x < y
if p < 0 then
x = x + 1
y=y
p = p+2*x+1;
else
x = x + 1
y = y - 1;
p = p + 2 * ( x – y ) + 1
plotspoints( )
Stop

7. poltpoints( )
setpixel ( xc + x, yc + y, 1 )
setpixel ( xc +x, yc - y, 1 )
setpixel ( xc - x, yc + y, 1 )
setpixel ( xc - x, yc - y, 1 )
setpixel ( xc + y, yc + x, 1 )
setpixel ( xc + y, yc - x, 1 )
setpixel ( xc - y, yc + x, 1 )
setpixel ( xc - y, yc - x, 1 )
STOP

No comments:

Post a Comment