10 REM PEANO CURVES
20 REM FIRST PUBLISHED ON COMMODORE COMPUTER CLUB #27
30 REM CODE BY DANILO TOMA
40 REM PORTED TO LM80C BASIC BY LEONARDO MILIANI
100 SCREEN 1:PI=3.14159
110 LOCATE 4,3:PRINT "P E A N O    C U R V E S":LOCATE 0,8
115 PRINT "Enter the trasformation type T,"
120 PRINT "the number of curves C, and the"
125 PRINT "order number O, separated by "
130 PRINT "commas (Values in range 0-9)."
150 PRINT "T,C,O";:INPUT P$,S$,N$
160 P=VAL(P$):S=VAL(S$):N=VAL(N$)
170 IF P<=0 OR S<=0 OR N<=0 THEN 150
180 IF P>9 OR S>9 OR N>9 THEN 150
190 PAUSE 100
245 SCREEN 2
250 GR=-2*PI/P:R=-2*PI/S
260 FOR I=2 TO P-1
270 D(I)=-GR
280 NEXT
290 D(1)=GR*(P-2)/2
300 D(P)=D(1)
320 X1=127:Y1=0:AN=R/2+PI
330 L=191*SIN(R/2)/3^N
350 FOR I=1 TO S:REM NUMBER OF CURVERS
370 FOR K=1 TO N
380 O(K)=0:REM CYCLES INIT.
390 NEXT
410 GOSUB 660:REM COMPUTE
430 AN=AN+R:REM DIRECTION OF
440 NEXT:REM NEXT SIDE
460 REM END
470 VOLUME 1,15:SOUND 1,4000,20
480 GPRINT "Again (Y/N)?",0,23:A=INKEY(10)
490 A=INKEY(10) AND 223:IF A=0 THEN 490
500 IF A=ASC("Y") THEN 100
510 SCREEN 1:END
580 REM DRAW CURVE
590 K=0
600 K=K+1
610 IF K>N THEN RETURN
620 IF O(K)=P THEN O(K)=0:GOTO 600
630 O(K)=O(K)+1
640 AN=AN+D(O(K))
660 X2=X1+COS(AN)*L
670 Y2=Y1-SIN(AN)*L
675 GOSUB 800
680 DRAW X1,Y1,X2,Y2
690 X1=X2:Y1=Y2
700 GOTO 590
800 WS=255:PK=X1:GOSUB 1000:X1=PK
810 PK=X2:GOSUB 1000:X2=PK
820 WS=191:PK=Y1:GOSUB 1000:Y1=PK
830 PK=Y2:GOSUB 1000:Y2=PK
840 RETURN
1000 IF PK<0 THEN PK=0:RETURN
1010 IF PK>WS THEN PK=WS:RETURN
1020 RETURN
