Ice Fractal

 投稿者:しばっち  投稿日:2015年10月28日(水)22時08分25秒
 
!'Ice Fractal
PUBLIC NUMERIC X,Y,ALPHA
CALL GINIT(800,800)
INPUT PROMPT "LEVEL=":N
LET MODE=0
SELECT CASE MODE
CASE 0
   LET L=600
   LET X=100
   LET Y=700
   FOR I=1 TO 3
      CALL RECURSIVE(N,L)
      CALL TURN(120)
   NEXT I
CASE 1
   LET L=600
   LET X=100
   LET Y=700
   FOR I=1 TO 4
      CALL RECURSIVE(N,L)
      CALL TURN(90)
   NEXT I
CASE 2
   LET L=600
   LET X=100
   LET Y=600
   CALL TURN(60)
   FOR I=1 TO 3
      CALL RECURSIVE(N,L)
      CALL TURN(-120)
   NEXT I
CASE 3
   LET L=500
   LET X=150
   LET Y=650
   CALL TURN(90)
   FOR I=1 TO 4
      CALL RECURSIVE(N,L)
      CALL TURN(-90)
   NEXT I
CASE 4
   LET L=600
   LET X=100
   LET Y=700
   FOR I=1 TO 4
      CALL RECURSIVE2(N,L)
      CALL TURN(90)
   NEXT I
CASE 5
   LET L=400
   LET X=200
   LET Y=600
   CALL TURN(90)
   FOR I=1 TO 4
      CALL RECURSIVE2(N,L)
      CALL TURN(-90)
   NEXT I
END SELECT
END

EXTERNAL SUB RECURSIVE(LEV,L)
IF LEV=0 THEN
   CALL MOVE(L)
ELSE
   CALL RECURSIVE(LEV-1,L/2)
   CALL TURN(120)
   CALL RECURSIVE(LEV-1,L/4)
   CALL TURN(-180)
   CALL RECURSIVE(LEV-1,L/4)
   CALL TURN(120)
   CALL RECURSIVE(LEV-1,L/4)
   CALL TURN(-180)
   CALL RECURSIVE(LEV-1,L/4)
   CALL TURN(120)
   CALL RECURSIVE(LEV-1,L/2)
END IF
END SUB

EXTERNAL SUB RECURSIVE2(LEV,L)
IF LEV=0 THEN
   CALL MOVE(L)
ELSE
   CALL RECURSIVE2(LEV-1,L/2)
   CALL TURN(90)
   CALL RECURSIVE2(LEV-1,L/3)
   CALL TURN(-180)
   CALL RECURSIVE2(LEV-1,L/3)
   CALL TURN(90)
   CALL RECURSIVE2(LEV-1,L/2)
END IF
END SUB

EXTERNAL SUB GINIT(XSIZE,YSIZE)
SET BITMAP SIZE XSIZE,YSIZE
SET WINDOW 0,XSIZE-1,YSIZE-1,0
SET POINT STYLE 1
SET COLOR MODE "REGULAR"
SET COLOR MIX(0) 0,0,0
SET COLOR MIX(1) 0,0,1
SET COLOR MIX(2) 1,0,0
SET COLOR MIX(3) 1,0,1
SET COLOR MIX(4) 0,1,0
SET COLOR MIX(5) 0,1,1
SET COLOR MIX(6) 1,1,0
SET COLOR MIX(7) 1,1,1
CLEAR
SET COLOR 7
END SUB

EXTERNAL SUB MOVE(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;
END SUB

EXTERNAL SUB TURN(R)
LET ALPHA=MOD(ALPHA+R+360,360)
END SUB
 

戻る