home *** CD-ROM | disk | FTP | other *** search
- {fast fillcircle routine using FastDraw or Turbo's DRAW}
- TITLE: Filling Circles
-
- procedure FillCircle(cx,cy,radius,color:integer);
- var x,y,d: integer;
- hold:array[0..199] of record yes,left,right:integer end;
-
- procedure Jot(x,y:integer);
- begin
- if y>=0 then {y axis clipping} if y<200 then
- with hold[y] do
- if yes=0 then begin yes:=1; left:=x;right:=x end
- else if x<left then left:=x
- else if x>right then right:=x;
- end; {Jot}
-
- procedure EightPoints(x,y,ox,oy,c:integer);
- const aspect = 50; {50 for 640x200, 25 for 320x200}
- var ax,px,py,nx,ny: integer;
- begin
- ax := (aspect*abs(x)+11) div 22;
- px := ox + ax; py := oy + y;
- nx := ox - ax; ny := oy - y;
- Jot(px,py);
- Jot(px,ny);
- Jot(nx,py);
- Jot(nx,ny);
- ax := (aspect*abs(y)+11) div 22;
- px := ox + ax; py := oy + x;
- nx := ox - ax; ny := oy - x;
- Jot(px,py);
- Jot(px,ny);
- Jot(nx,py);
- Jot(nx,ny);
- end;
-
- procedure fill;
- var i:integer;
- const maxx = 639; {use 639 for HiRes clipping, 319 for GraphMode}
- begin
- for i:=0 to 199 do
- with hold[i] do
- if yes=1 then
- begin {x clipping with 0 to maxx}
- if left<0 then left:=0;
- if right>maxx then right:=maxx;
- if left<=right then FastDraw(left,i,right,i,color);
- end;
- end; {Fill}
-
- begin {FillCircle}
- FillChar(Hold,SIZEOF(Hold),0); {set all yes's to zero}
- x:=0;
- y := radius;
- d := 3 - 2*radius;
- while x<y do begin
- EightPoints(x,y,cx,cy,color);
- if d<0 then
- d := d + 4*x + 6
- else begin
- d := d + 4*(x-y) + 10;
- y := y - 1
- end;
- x := x + 1
- end; { while }
- if x = y then
- EightPoints(x,y,cx,cy,color);
- Fill;
- end; {FillCircle}
-