home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
NEWS
/
554
/
JUIN
/
ELLIPSE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-10-07
|
2KB
|
43 lines
{─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
Msg : 385 of 393
From : Sean Palmer 1:104/123.0 12 Jun 93 00:05
To : Wouter Goderis
Subj : Circle 320x200x256
────────────────────────────────────────────────────────────────────────────────
WG> does someone have a circle routine for the 320x200x256 mode.
WG> I need one using the assembler... (FAST) ( or isn't that
WG> possible) I doesn't need to be very perfect, if it has the
WG> shape of a circle, I'm satisfied.
WG> Can someone give me some hints ?
Just noticed a big, slow circle routine being posted at you and thought
you'd be more interested in this general-purpose ellipse routine... just
call it with a and b both equal to the desired radius and it'll make a
circle (with 1:1 aspect ratio)
LOTS faster than anything that uses SQRT()
I'm sure you can figure out how to make a PLOT() routine...}
procedure oval(xc,yc,a,b:integer);
var x,y:integer;aa,aa2,bb,bb2,d,dx,dy:longint;
begin
x:=0;y:=b;
aa:=longint(a)*a;aa2:=2*aa;
bb:=longint(b)*b;bb2:=2*bb;
d:=bb-aa*b+aa div 4;
dx:=0;dy:=aa2*b;
plot(xc,yc-y);plot(xc,yc+y);plot(xc-a,yc);plot(xc+a,yc);
while(dx<dy)do begin
if(d>0)then begin dec(y); dec(dy,aa2); dec(d,dy); end;
inc(x); inc(dx,bb2); inc(d,bb+dx);
plot(xc+x,yc+y); plot(xc-x,yc+y); plot(xc+x,yc-y); plot(xc-x,yc-y);
end;
inc(d,(3*(aa-bb)div 2-(dx+dy))div 2);
while(y>0)do begin
if(d<0)then begin inc(x); inc(dx,bb2); inc(d,bb+dx); end;
dec(y); dec(dy,aa2); inc(d,aa-dy);
plot(xc+x,yc+y); plot(xc-x,yc+y); plot(xc+x,yc-y); plot(xc-x,yc-y);
end;
end;