fractal1.py

Created by schraf

Created on September 03, 2022

536 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(400):
  x = (a - 320) / 200
  y = (b - 200) / 200
  i, d, c = 0, 100, True
  while c:
    u, v = x*x, y*y
    if u + v > 2.4 or i > 50 or d < .05:
      c = False
    else:
      t = u - v
      y = 2 * x * y + .156
      x = t - .8
      i += 1
      n = u + v
      if n < d: d = n
  if d < .03:
    coul = max(0,255 - int(1e4 * d))
    set_pixel(a//2, b//2, (coul,coul,0))
    set_pixel(319 - a//2, 199 - b//2, (coul,coul,0))