-
Notifications
You must be signed in to change notification settings - Fork 2
/
snowflake.BAS
43 lines (39 loc) · 1.22 KB
/
snowflake.BAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
10 COLOR 15,1,1
20 OPEN "GRP:" FOR OUTPUT AS #1
30 SCREEN 1:KEY OFF:CLS
40 LOCATE 6, 1: PRINT "SNOWFLAKE GENERATOR"
50 LOCATE 1, 6:PRINT "S: Use Snowflake ID"
60 LOCATE 1, 8:PRINT "Any Key: Random Snowflake"
70 LOCATE 8,20:PRINT "By Raul Portales 2021"
80 A$=INKEY$:IF A$="" GOTO 80
90 IF A$="S" OR A$="s" THEN 95 ELSE S=TIME:GOTO 100
95 LOCATE 1,12:INPUT "Enter Snowflake ID";S
100 'GENERATE SNOWFLAKE
100 R=RND(-TIME)
110 SCREEN 2
120 PRESET(0,0):PRINT#1,"Snowflake ID (seed):"S
200 M2=0:A2=0:M=0
210 'RANDOMIZE NUMBER AND LENGTH OF SEGMENTS
220 NS=RND(1)*5+5:SL=90/NS
230 FOR J=0 TO NS
240 M=M+RND(1)*SL:A=RND(1)*.5
250 GOSUB 1000
260 NEXT J
270 'CONVERGE
280 A=0:GOSUB 1000
450 PRESET(0,180):PRINT#1,"Press any key to draw another"
460 IF INKEY$<>"" GOTO 460
470 IF INKEY$="" GOTO 470
500 GOTO 30
1000 ' SUBROUTINE TO DRAW FROM M1, A1 TO M2, A2 ON ALL POSITIONS AND ROTATIONS
1010 M1=M2:A1=A2:M2=M:A2=A
1020 FOR I=0 TO 3
1030 AI=1.0472*I
1040 X1=SIN(A1+AI)*M1:Y1=COS(A1+AI)*M1
1050 X2=SIN(A2+AI)*M2:Y2=COS(A2+AI)*M2
1060 LINE (128+X1,96+Y1)-(128+X2,96+Y2),15
1070 LINE (128+X1,96-Y1)-(128+X2,96-Y2),15
1080 LINE (128-X1,96-Y1)-(128-X2,96-Y2),15
1090 LINE (128-X1,96+Y1)-(128-X2,96+Y2),15
1100 NEXT I
1110 RETURN