-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphyllo.bas
268 lines (268 loc) · 10.5 KB
/
phyllo.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
1000 ' Phyllotaxis
1010 ' Gilbert Francois Duivesteijn
1020 '
1030 '
1040 '
1050 COLOR 1, 15, 15
1060 CLS
1070 ' *******************************
1080 ' Constants
1090 C0=4: ' radius scalar
1100 RC=C0-0: ' radius of elements
1110 RM=12: ' radius for color change
1120 NM=2000: ' max nr of elements
1125 CM=11: ' max nr of colors
1130 DIM CP(CM+1): ' colour palette
1140 CP(0)=12
1150 CP(1)=2
1160 CP(2)=3
1170 CP(3)=11
1180 CP(4)=10
1190 CP(5)=9
1200 CP(6)=8
1210 CP(7)=6
1220 CP(8)=14
1230 CP(9)=15
1240 CP(10)=15
1250 CP(11)=15
1260 ' *******************************
1270 OPEN "grp:" FOR OUTPUT AS #1
1280 PI=ATN(1)*4
1290 ' sin(x) lookup table from
1300 ' 0 to 359 degrees.
1310 DIM TBL(360)
1320 PRINT "Building lookup table, please wait..."
1330 GOSUB 3120
1340 ' Fast sin(x) function
1350 DEF FN FS(X)=TBL((X+.5) MOD 360)
1360 ' Fast cos(x) function
1370 DEF FN FC(X)=TBL((X+90.5) MOD 360)
1380 ' Main
1390 SCREEN 2
1400 CI=0: ' colour index
1410 A=0 : ' first angle
1420 FOR N=1 TO NM
1440 A=A+137.5
1450 IF A>360 THEN A=A-360
1460 R=C0*SQR(N)
1470 CI=CINT(R/RM)
1480 IF CI>CM THEN CI=CM
1490 CO=CP(CI)
1520 X = CINT(R*(FN FC(A))+96+.5)+32
1530 Y = CINT(R*(FN FS(A))+96+.5)
1561 IF R<(96-(RC*.5)) GOTO 1570 ELSE 1580
1570 GOSUB 2000: ' Draw element
1580 NEXT N
1590 GOTO 1590
2000 '
2010 ' Draw element
2020 ' in: X, Y, RC, CO
2030 '
2040 ' IF R<(90-RC) THEN CIRCLE(X,Y),RC,CO
2041 CIRCLE(X,Y),RC,CO
2050 PSET(X,Y),CO
2060 RETURN
3000 '
3010 ' Print label
3020 ' in: A0, B0, LB$
3030 '
3040 IF LB$="0" THEN LB$="0000"
3050 FOR I=1 TO LEN(LB$)
3060 DRAW "BM"+STR$(A0+6*I)+","+STR$(B0)
3070 'PRESET(A0+6*I,B0),CB
3080 COLOR CF
3090 PRINT #1,MID$(LB$,I,1)
3100 NEXT I
3110 RETURN
3120 '
3130 ' Create lookup tables
3140 '
3150 ' in : tbl: sin lookup table
3160 ' out: tbl
3170 '
3180 FOR I=0 TO 359
3190 READ TBL(I)
3200 NEXT I
3210 RETURN
3220 END
3230 DATA 0.000000000000000, 0.017452406437284
3240 DATA 0.034899496702501, 0.052335956242944
3250 DATA 0.069756473744125, 0.087155742747658
3260 DATA 0.104528463267653, 0.121869343405147
3270 DATA 0.139173100960065, 0.156434465040231
3280 DATA 0.173648177666930, 0.190808995376545
3290 DATA 0.207911690817759, 0.224951054343865
3300 DATA 0.241921895599668, 0.258819045102521
3310 DATA 0.275637355816999, 0.292371704722737
3320 DATA 0.309016994374947, 0.325568154457157
3330 DATA 0.342020143325669, 0.358367949545300
3340 DATA 0.374606593415912, 0.390731128489274
3350 DATA 0.406736643075800, 0.422618261740699
3360 DATA 0.438371146789077, 0.453990499739547
3370 DATA 0.469471562785891, 0.484809620246337
3380 DATA 0.500000000000000, 0.515038074910054
3390 DATA 0.529919264233205, 0.544639035015027
3400 DATA 0.559192903470747, 0.573576436351046
3410 DATA 0.587785252292473, 0.601815023152048
3420 DATA 0.615661475325658, 0.629320391049837
3430 DATA 0.642787609686539, 0.656059028990507
3440 DATA 0.669130606358858, 0.681998360062498
3450 DATA 0.694658370458997, 0.707106781186547
3460 DATA 0.719339800338651, 0.731353701619170
3470 DATA 0.743144825477394, 0.754709580222772
3480 DATA 0.766044443118978, 0.777145961456971
3490 DATA 0.788010753606722, 0.798635510047293
3500 DATA 0.809016994374947, 0.819152044288992
3510 DATA 0.829037572555042, 0.838670567945424
3520 DATA 0.848048096156426, 0.857167300702112
3530 DATA 0.866025403784439, 0.874619707139396
3540 DATA 0.882947592858927, 0.891006524188368
3550 DATA 0.898794046299167, 0.906307787036650
3560 DATA 0.913545457642601, 0.920504853452440
3570 DATA 0.927183854566787, 0.933580426497202
3580 DATA 0.939692620785908, 0.945518575599317
3590 DATA 0.951056516295154, 0.956304755963035
3600 DATA 0.961261695938319, 0.965925826289068
3610 DATA 0.970295726275996, 0.974370064785235
3620 DATA 0.978147600733806, 0.981627183447664
3630 DATA 0.984807753012208, 0.987688340595138
3640 DATA 0.990268068741570, 0.992546151641322
3650 DATA 0.994521895368273, 0.996194698091746
3660 DATA 0.997564050259824, 0.998629534754574
3670 DATA 0.999390827019096, 0.999847695156391
3680 DATA 1.000000000000000, 0.999847695156391
3690 DATA 0.999390827019096, 0.998629534754574
3700 DATA 0.997564050259824, 0.996194698091746
3710 DATA 0.994521895368273, 0.992546151641322
3720 DATA 0.990268068741570, 0.987688340595138
3730 DATA 0.984807753012208, 0.981627183447664
3740 DATA 0.978147600733806, 0.974370064785235
3750 DATA 0.970295726275996, 0.965925826289068
3760 DATA 0.961261695938319, 0.956304755963036
3770 DATA 0.951056516295154, 0.945518575599317
3780 DATA 0.939692620785908, 0.933580426497202
3790 DATA 0.927183854566787, 0.920504853452440
3800 DATA 0.913545457642601, 0.906307787036650
3810 DATA 0.898794046299167, 0.891006524188368
3820 DATA 0.882947592858927, 0.874619707139396
3830 DATA 0.866025403784439, 0.857167300702112
3840 DATA 0.848048096156426, 0.838670567945424
3850 DATA 0.829037572555042, 0.819152044288992
3860 DATA 0.809016994374947, 0.798635510047293
3870 DATA 0.788010753606722, 0.777145961456971
3880 DATA 0.766044443118978, 0.754709580222772
3890 DATA 0.743144825477394, 0.731353701619171
3900 DATA 0.719339800338651, 0.707106781186548
3910 DATA 0.694658370458997, 0.681998360062498
3920 DATA 0.669130606358858, 0.656059028990507
3930 DATA 0.642787609686539, 0.629320391049837
3940 DATA 0.615661475325658, 0.601815023152048
3950 DATA 0.587785252292473, 0.573576436351046
3960 DATA 0.559192903470747, 0.544639035015027
3970 DATA 0.529919264233205, 0.515038074910054
3980 DATA 0.500000000000000, 0.484809620246337
3990 DATA 0.469471562785891, 0.453990499739547
4000 DATA 0.438371146789077, 0.422618261740699
4010 DATA 0.406736643075800, 0.390731128489274
4020 DATA 0.374606593415912, 0.358367949545300
4030 DATA 0.342020143325669, 0.325568154457157
4040 DATA 0.309016994374948, 0.292371704722737
4050 DATA 0.275637355816999, 0.258819045102521
4060 DATA 0.241921895599668, 0.224951054343865
4070 DATA 0.207911690817759, 0.190808995376545
4080 DATA 0.173648177666930, 0.156434465040231
4090 DATA 0.139173100960065, 0.121869343405148
4100 DATA 0.104528463267654, 0.087155742747658
4110 DATA 0.069756473744126, 0.052335956242944
4120 DATA 0.034899496702501, 0.017452406437283
4130 DATA 0.000000000000000, -0.017452406437284
4140 DATA -0.034899496702501, -0.052335956242944
4150 DATA -0.069756473744125, -0.087155742747658
4160 DATA -0.104528463267653, -0.121869343405147
4170 DATA -0.139173100960066, -0.156434465040231
4180 DATA -0.173648177666930, -0.190808995376545
4190 DATA -0.207911690817760, -0.224951054343865
4200 DATA -0.241921895599668, -0.258819045102521
4210 DATA -0.275637355816999, -0.292371704722737
4220 DATA -0.309016994374947, -0.325568154457157
4230 DATA -0.342020143325669, -0.358367949545300
4240 DATA -0.374606593415912, -0.390731128489274
4250 DATA -0.406736643075800, -0.422618261740699
4260 DATA -0.438371146789077, -0.453990499739547
4270 DATA -0.469471562785891, -0.484809620246337
4280 DATA -0.500000000000000, -0.515038074910054
4290 DATA -0.529919264233205, -0.544639035015027
4300 DATA -0.559192903470747, -0.573576436351046
4310 DATA -0.587785252292473, -0.601815023152048
4320 DATA -0.615661475325658, -0.629320391049838
4330 DATA -0.642787609686539, -0.656059028990507
4340 DATA -0.669130606358858, -0.681998360062498
4350 DATA -0.694658370458997, -0.707106781186547
4360 DATA -0.719339800338651, -0.731353701619170
4370 DATA -0.743144825477394, -0.754709580222772
4380 DATA -0.766044443118978, -0.777145961456971
4390 DATA -0.788010753606722, -0.798635510047293
4400 DATA -0.809016994374947, -0.819152044288992
4410 DATA -0.829037572555042, -0.838670567945424
4420 DATA -0.848048096156426, -0.857167300702112
4430 DATA -0.866025403784438, -0.874619707139396
4440 DATA -0.882947592858927, -0.891006524188368
4450 DATA -0.898794046299167, -0.906307787036650
4460 DATA -0.913545457642601, -0.920504853452440
4470 DATA -0.927183854566787, -0.933580426497202
4480 DATA -0.939692620785908, -0.945518575599317
4490 DATA -0.951056516295154, -0.956304755963035
4500 DATA -0.961261695938319, -0.965925826289068
4510 DATA -0.970295726275996, -0.974370064785235
4520 DATA -0.978147600733806, -0.981627183447664
4530 DATA -0.984807753012208, -0.987688340595138
4540 DATA -0.990268068741570, -0.992546151641322
4550 DATA -0.994521895368273, -0.996194698091746
4560 DATA -0.997564050259824, -0.998629534754574
4570 DATA -0.999390827019096, -0.999847695156391
4580 DATA -1.000000000000000, -0.999847695156391
4590 DATA -0.999390827019096, -0.998629534754574
4600 DATA -0.997564050259824, -0.996194698091746
4610 DATA -0.994521895368273, -0.992546151641322
4620 DATA -0.990268068741570, -0.987688340595138
4630 DATA -0.984807753012208, -0.981627183447664
4640 DATA -0.978147600733806, -0.974370064785235
4650 DATA -0.970295726275997, -0.965925826289068
4660 DATA -0.961261695938319, -0.956304755963035
4670 DATA -0.951056516295154, -0.945518575599317
4680 DATA -0.939692620785908, -0.933580426497202
4690 DATA -0.927183854566787, -0.920504853452440
4700 DATA -0.913545457642601, -0.906307787036650
4710 DATA -0.898794046299167, -0.891006524188368
4720 DATA -0.882947592858927, -0.874619707139396
4730 DATA -0.866025403784439, -0.857167300702112
4740 DATA -0.848048096156426, -0.838670567945424
4750 DATA -0.829037572555042, -0.819152044288992
4760 DATA -0.809016994374948, -0.798635510047293
4770 DATA -0.788010753606722, -0.777145961456971
4780 DATA -0.766044443118978, -0.754709580222772
4790 DATA -0.743144825477395, -0.731353701619170
4800 DATA -0.719339800338651, -0.707106781186548
4810 DATA -0.694658370458998, -0.681998360062498
4820 DATA -0.669130606358858, -0.656059028990507
4830 DATA -0.642787609686540, -0.629320391049838
4840 DATA -0.615661475325658, -0.601815023152048
4850 DATA -0.587785252292473, -0.573576436351046
4860 DATA -0.559192903470747, -0.544639035015027
4870 DATA -0.529919264233205, -0.515038074910054
4880 DATA -0.500000000000000, -0.484809620246337
4890 DATA -0.469471562785891, -0.453990499739547
4900 DATA -0.438371146789078, -0.422618261740699
4910 DATA -0.406736643075800, -0.390731128489274
4920 DATA -0.374606593415912, -0.358367949545301
4930 DATA -0.342020143325669, -0.325568154457157
4940 DATA -0.309016994374948, -0.292371704722737
4950 DATA -0.275637355816999, -0.258819045102521
4960 DATA -0.241921895599668, -0.224951054343865
4970 DATA -0.207911690817760, -0.190808995376545
4980 DATA -0.173648177666930, -0.156434465040231
4990 DATA -0.139173100960066, -0.121869343405147
5000 DATA -0.104528463267653, -0.087155742747658
5010 DATA -0.069756473744126, -0.052335956242944
5020 DATA -0.034899496702501, -0.017452406437284