§ Иллюстрация


На картинку можно нажимать, чтобы приблизить или отдалить.

§ Код программы

1SCREEN 13
2
3setpalette
4f = 2.441406E-04
5x0 = -1.022217#
6y0 = -.3725586#
7
8WHILE 1
9
10  fractal x0, y0, f
11  LOCATE 25, 1: PRINT x0; y0; f;
12
13  SELECT CASE getch
14    CASE 1: y0 = y0 + f
15    CASE 2: x0 = x0 + f
16    CASE 3: y0 = y0 - f
17    CASE 4: x0 = x0 - f
18    CASE 13: f = f / 2
19    CASE 8: f = f * 2
20    CASE 27: END
21  END SELECT
22
23WEND
24
25SUB fractal (x0, y0, f)
26
27  DIM xc AS DOUBLE
28  DIM yc AS DOUBLE
29
30  FOR y = -100 TO 99
31  FOR x = -160 TO 159
32    xc = f * x / 100 + x0
33    yc = f * y / 100 + y0
34    c = mandel(xc, yc)
35    PSET (160 + x, 100 - y), c
36  NEXT
37  NEXT
38
39END SUB
40
41FUNCTION getch
42
43DO
44
45  DO: i$ = INKEY$: LOOP WHILE i$ = ""
46
47  k = ASC(MID$(i$, 1, 1))
48  IF i$ = CHR$(0) + "H" THEN k = 1
49  IF i$ = CHR$(0) + "M" THEN k = 2
50  IF i$ = CHR$(0) + "P" THEN k = 3
51  IF i$ = CHR$(0) + "K" THEN k = 4
52
53LOOP WHILE k = 0
54
55getch = k
56
57END FUNCTION
58
59FUNCTION mandel (cx AS DOUBLE, cy AS DOUBLE)
60
61mandel = 0
62x = 0
63y = 0
64
65FOR i = 0 TO 63
66
67  xt = x ^ 2 - y ^ 2 + cx
68  yt = 2 * x * y + cy
69
70  x = xt
71  y = yt
72
73  IF x ^ 2 + y ^ 2 >= 4 THEN mandel = i: EXIT FOR
74
75NEXT
76
77END FUNCTION
78
79SUB setpalette
80
81FOR i = 0 TO 63
82  OUT 968, i
83  OUT 969, i
84  OUT 969, i
85  OUT 969, i \ 2 + 32
86NEXT
87
88END SUB