Apple II : Hilbert curve

 

Увидено в паблике:

0 GOTO 200

10 X = X + DX: Y = Y + DY: IF X < 0 OR Y< 0 OR X>279 OR Y>191 THEN N=1: RETURN

20 IF N THEN HPLOT X,Y: N=0: RETURN

30 HPLOT TO X,Y: N=0: RETURN

40 ODER = ODER-1

50 TURN = - TURN: TMP = DY: DY =-TURN * DX: DX = TURN * TMP: IF ODER>0 THEN GOSUB 40

60 GOSUB 10

70 TURN = - TURN: TMP = DY: DY =-TURN * DX: DX = TURN * TMP: IF ODER>0 THEN GOSUB 40

80 GOSUB 10: IF ODER>0 THEN GOSUB 40

90 TMP = DY: DY =-TURN * DX: DX = TURN * TMP: TURN = -TURN

100 GOSUB 10: IF ODER>0 THEN GOSUB 40

110 TMP = DY: DY =-TURN * DX: DX = TURN * TMP: TURN = - TURN

120 ODER = ODER + 1: RETURN 

200 HOME

210 INPUT "ODER (2-20) "; ODER

220 TURN=-1

230 DY=50/ODER

240 INPUT "TILT (0-...) "; DX

250 X=0:Y=0: HGR2: HCOLOR=3

260 HPLOT X,Y

270 GOSUB 40

Дополнение. Другая версия на другом диалекте

110 CLS 3
120 ODER=5
130 TURN=-1
140 DY=50/ODER
150 DX=0:X=0:Y=0
160 X=100:Y=50
170 PSET(X,Y),4
180 GOSUB 200
190 END
200 ODER=ODER-1
210 TURN=-TURN
220 TMP=DY:DY=-TURN*DX:DX=TURN*TMP
230 IF ODER>0 THEN GOSUB 200
240 X=X+DX:Y=Y+DY:LINE-(X,Y),4
250 TURN=-TURN
260 TMP=DY:DY=-TURN*DX:DX=TURN*TMP
270 IF ODER>0 THEN GOSUB 200
280 X=X+DX:Y=Y+DY:LINE-(X,Y),4
290 IF ODER>0 THEN GOSUB 200
300 TMP=DY:DY=-TURN*DX:DX=TURN*TMP
310 TURN=-TURN
320 X=X+DX:Y=Y+DY:LINE-(X,Y),4
330 IF ODER>0 THEN GOSUB 200
340 TMP=DY:DY=-TURN*DX:DX=TURN*TMP
350 TURN=-TURN
360 ODER=ODER+1
370 RETURN



Комментарии