home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-386-Vol-2of3.iso
/
b
/
baswiz19.zip
/
BW$BAS.ZIP
/
G13ELLIP.BAS
< prev
next >
Wrap
BASIC Source File
|
1993-01-29
|
2KB
|
63 lines
' +----------------------------------------------------------------------+
' | |
' | BASWIZ Copyright (c) 1990-1993 Thomas G. Hanlin III |
' | |
' | The BASIC Wizard's Library |
' | |
' +----------------------------------------------------------------------+
' this routine is based on the midpoint ellipse algorithm as expressed in the
' book "Programmer's Guide to PC & PS/2 Video Displays", by Richard Wilton,
' Microsoft Press.
DECLARE SUB G13Line (BYVAL X1%, BYVAL Y1%, BYVAL X2%, BYVAL Y2%)
DECLARE SUB G13Plot (BYVAL X%, BYVAL Y%)
DEFINT A-Z
SUB G13Ellipse (CenterX, CenterY, XRad, YRadius)
XRadius = XRad * 1.2
IF XRadius = 0 THEN
G13Line CenterX, CenterY - YRadius, CenterX, CenterY + YRadius
ELSEIF YRadius = 0 THEN
G13Line CenterX - XRadius, CenterY, CenterX + XRadius, CenterY
ELSE
X = 0
Y = YRadius
A& = XRadius
B& = YRadius
D& = B& * B& - A& * A& * B& + (A& * A&) \ 4&
DX& = 0&
DY& = 2 * A& * A& * B&
DO WHILE DX& < DY&
G13Plot CenterX + X, CenterY + Y
G13Plot CenterX + X, CenterY - Y
G13Plot CenterX - X, CenterY + Y
G13Plot CenterX - X, CenterY - Y
IF D& > 0& THEN
Y = Y - 1
DY& = DY& - 2& * A& * A&
D& = D& - DY&
END IF
X = X + 1
DX& = DX& + 2& * B& * B&
D& = D& + B& * B& + DX&
LOOP
D& = D& + (3& * (A& * A& - B& * B&) \ 2& - (DX& + DY&)) \ 2&
DO WHILE Y >= 0
G13Plot CenterX + X, CenterY + Y
G13Plot CenterX + X, CenterY - Y
G13Plot CenterX - X, CenterY + Y
G13Plot CenterX - X, CenterY - Y
IF D& < 0& THEN
X = X + 1
DX& = DX& + B& * B& * 2&
D& = D& + DX&
END IF
Y = Y - 1
DY& = DY& - A& * A& * 2&
D& = D& + A& * A& - DY&
LOOP
END IF
END SUB