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


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

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

SCREEN 13

setpalette
f = 2.441406E-04
x0 = -1.022217#
y0 = -.3725586#

WHILE 1

  fractal x0, y0, f
  LOCATE 25, 1: PRINT x0; y0; f;

  SELECT CASE getch
    CASE 1: y0 = y0 + f
    CASE 2: x0 = x0 + f
    CASE 3: y0 = y0 - f
    CASE 4: x0 = x0 - f
    CASE 13: f = f / 2
    CASE 8: f = f * 2
    CASE 27: END
  END SELECT

WEND

SUB fractal (x0, y0, f)

  DIM xc AS DOUBLE
  DIM yc AS DOUBLE

  FOR y = -100 TO 99
  FOR x = -160 TO 159
    xc = f * x / 100 + x0
    yc = f * y / 100 + y0
    c = mandel(xc, yc)
    PSET (160 + x, 100 - y), c
  NEXT
  NEXT

END SUB

FUNCTION getch

DO

  DO: i$ = INKEY$: LOOP WHILE i$ = ""

  k = ASC(MID$(i$, 1, 1))
  IF i$ = CHR$(0) + "H" THEN k = 1
  IF i$ = CHR$(0) + "M" THEN k = 2
  IF i$ = CHR$(0) + "P" THEN k = 3
  IF i$ = CHR$(0) + "K" THEN k = 4

LOOP WHILE k = 0

getch = k

END FUNCTION

FUNCTION mandel (cx AS DOUBLE, cy AS DOUBLE)

mandel = 0
x = 0
y = 0

FOR i = 0 TO 63

  xt = x ^ 2 - y ^ 2 + cx
  yt = 2 * x * y + cy

  x = xt
  y = yt

  IF x ^ 2 + y ^ 2 >= 4 THEN mandel = i: EXIT FOR

NEXT

END FUNCTION

SUB setpalette

FOR i = 0 TO 63
  OUT 968, i
  OUT 969, i
  OUT 969, i
  OUT 969, i \ 2 + 32
NEXT

END SUB
30 мая, 2020
© 2007-2022 Фрамуга штырит отлично