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))

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.