|
ペアノ曲線(Peano Curve)
https://ja.wikipedia.org/wiki/ペアノ曲線
PUBLIC NUMERIC X,Y,ALPHA,XYMAX
LET XSIZE=600
LET YSIZE=600
CALL GINIT(XSIZE,YSIZE)
INPUT PROMPT "LEVEL(1-8)=":N
LET X=5
LET Y=5
LET LENGTH=100
CALL PEANO(N,90,LENGTH)
IF XYMAX>XSIZE OR XYMAX>YSIZE THEN
CLEAR
SET WINDOW 0,XYMAX+5,0,XYMAX+5
LET X=5
LET Y=5
CALL PEANO(N,90,LENGTH)
END IF
END
EXTERNAL SUB PEANO(N,A,H)
IF N>0 THEN
CALL RT(A)
CALL PEANO(N-1,-A,H)
CALL FD(H)
CALL PEANO(N-1,A,H)
CALL FD(H)
CALL PEANO(N-1,-A,H)
CALL LT(A)
END IF
END SUB
EXTERNAL SUB GINIT(XSIZE,YSIZE)
SET BITMAP SIZE XSIZE,YSIZE
SET WINDOW 0,XSIZE-1,0,YSIZE-1
SET POINT STYLE 1
SET COLOR MODE "REGULAR"
FOR I=0 TO 7
SET COLOR MIX(I) BITAND(I,2)/2,BITAND(I,4)/4,BITAND(I,1)
NEXT I
CLEAR
SET COLOR 7
END SUB
EXTERNAL SUB FD(L)
PLOT LINES:X,Y;
LET X=X+L*COS(ALPHA*PI/180)
LET Y=Y-L*SIN(ALPHA*PI/180)
PLOT LINES:X,Y;
LET XYMAX=MAX(XYMAX,MAX(X,Y))
END SUB
EXTERNAL SUB LT(R)
LET ALPHA=MOD(ALPHA+R+360,360)
END SUB
EXTERNAL SUB RT(R)
LET ALPHA=MOD(ALPHA-R+360,360)
END SUB
|
|