fractal2.py

Created by schraf

Created on September 03, 2022

547 Bytes

Découvrez ma chaine YouTube (Python, JavaScript, calculatrices…)


from kandinsky import *

fill_rect(0,0,320,222,(0,0,0))

for a in range(320):
 for b in range(512):
  x = (a - 320) / 200
  y = (b - 256) / 200
  i, d, c = 0, 100, True
  while c:
    u, v = x*x, y*y
    if u + v > 2.4 or i > 19 or d < .12:
      c = False
    else:
      t = u - v
      y = 2 * x * y + .156
      x = t - .8
      i += 1
      n = abs(u + v - 1)
      if n < d: d = n
  if d < .07:
    coul = 255 - int(3640 * d)
    set_pixel(a//2, b//2 - 20, (coul,coul,0))
    set_pixel(319 - a//2, 235 - b//2, (coul,coul,0))