home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
058.lha
/
MathGraphic
(
.txt
)
< prev
next >
Wrap
AmigaBASIC Source Code
|
1986-11-20
|
3KB
|
163 lines
Mathgraphics:
GOSUB INITIALIZE
' REPEAT UNTIL THE USER PRESSES A KEY.
WHILE INKEY$=""
' MODULE 1: RightOvals
R1=150
R2=25
R3=25
R4=85
INC=PI/64
FOR THETA=0 TO 2*TWOPI STEP INC
X1=FNPOLARX(R1,THETA)
Y1=FNPOLARY(R2,THETA)
X2=FNPOLARX(R3,THETA+PI)
Y2=FNPOLARY(R4,THETA+PI)
LINE(X2,Y2)-(X1,Y1),INT(RND*31)+1
NEXT
PAUSE
' MODULE 2: SideOvals---
'SAME THING, ONLY DIFFERENT.
R1=150
R2=35
R3=65
R4=85
INC=PI/64
OFFSET=PI/3
FOR THETA=0 TO 3*TWOPI STEP INC
X1=FNPOLARX(R1,THETA)
Y1=FNPOLARY(R2,THETA)
X2=FNPOLARX(R3,THETA+OFFSET)
Y2=FNPOLARY(R4,THETA)
LINE(X1,Y1)-(X2,Y2),INT(RND*31)+1
NEXT
PAUSE
' MODULE 3: TWISTEDBAND
' YET ANOTHER VARIATION ON THE DOUBLE OVAL THEME.
R1=150
R2=35
R3=65
R4=85
INC=PI/64
OFFSET=PI/3
FOR THETA=0 TO 3*TWOPI STEP INC
X1=FNPOLARX(R1,THETA)
Y1=FNPOLARY(R2,THETA)
X2=FNPOLARX(R3,THETA)
Y2=FNPOLARY(R4,THETA+OFFSET)
LINE(X1,Y1)-(X2,Y2),INT(RND*31)+1
NEXT
PAUSE
'MODULE 4:MULTILOBE
R1=100
INC=PI/128
LOBES=4
FOR THETA=0 TO 2*TWOPI STEP INC
R2=R1*SIN(LOBES*THETA)
X1=FNPOLARX(R2,THETA)
Y1=FNPOLARY(R2,THETA)
LINE (XCENTER,YCENTER)-(X1,Y1),INT(RND*31)+1
NEXT
PAUSE
' MODULE 5: SPIRALCONE
R1=100
R2=85
INC=PI/160
LOBES=3
FOR THETA=0 TO 2*TWOPI STEP INC
X1=FNPOLARX(R1,THETA*LOBES)
Y1=FNPOLARY(R2,THETA)
LINE (XCENTER,YCENTER)-(X1,Y1),INT(RND*31)+1
NEXT
PAUSE
' MODULE 6: SIDESPIRAL CONE
R1=130
R2=80
INC=PI/160
LOBES=3
FOR THETA=0 TO 2*TWOPI STEP INC
X1=FNPOLARX(R1,THETA)
Y1=FNPOLARY(R2,THETA*LOBES)
LINE (XCENTER,YCENTER)-(X1,Y1),INT(RND*31)+1
NEXT
PAUSE
' MODULE 7:CIRCLES
R1=115
R2=85
R3=40
R4=45
INC1=PI/3
INC2=PI/20
FOR THETA1=0 TO TWOPI STEP INC1
FOR THETA2=0 TO TWOPI STEP INC2
X1=FNPOLARX(R1,THETA2)
Y1=FNPOLARY(R2,THETA2)
X2=FNPOLARX(R3,THETA1)
Y2=FNPOLARY(R4,THETA1)
LINE (X1,Y1)-(X2,Y2),INT(RND*31)+1
NEXT
NEXT
PAUSE
' MODULE 8: SPIKES
R1=115
R2=85
R3=40
R4=45
INC1=PI/3
INC2=PI/18
FOR THETA1=0 TO TWOPI STEP INC1
FOR THETA2=0 TO TWOPI STEP INC2
X1=FNPOLARX(R1,THETA2)
Y1=FNPOLARY(R2,THETA1)
X2=FNPOLARX(R3,THETA1)
Y2=FNPOLARY(R4,THETA2)
LINE (X1,Y1)-(X2,Y2),INT(RND*31)+1
NEXT
NEXT
PAUSE
WEND
' SHUT EVERYTHING DOWN AND QUIT.
WINDOW CLOSE 2
SCREEN CLOSE 2
WINDOW OUTPUT 1
END
SUB PAUSE STATIC
FOR DELAY=1 TO 5000
NEXT
CLS
END SUB
INITIALIZE:
' SET UP A 32 COLOR LOW-RES SCREEN.
SCREEN 2,320,200,5,1
WINDOW 2,"AmigaBasic Graphics",(0,0)-(297,185),23,2
CLS
' COLOR 0 (background) is black.
PALETTE 0,0,0,0
' SET UP OTHER 31 COLORS AS RANDOM COMBINATIONS.
FOR L=1 TO 31
PALETTE L,RND,RND,RND
NEXT
' KEEP THE RANDOM SEQUENCE RANDOM.
RANDOMIZE TIMER
' DEFINE CONSTANTS.
PI=3.14159
TWOPI=2*PI
XCENTER=151
YCENTER=93
'DEFINE POLAR TO CARTESIAN CONVERSION FUNCTIONS.
DEF FNPOLARX(R,THETA)=R*COS(THETA)+XCENTER
DEF FNPOLARY(R,THETA)=R*SIN(THETA)+YCENTER
RETURN