julia3.py

Created by vef03715

Created on February 01, 2021

2.27 KB


import kandinsky
def julia3(N_iteration):
  for x in range(320):
    for y in range(222):
#      z = complex(0,0)
#      c = complex(3.5*x/319-2.5, -2.5*y/221+1.25)
      c = complex(-0.8,0.156)
      z = complex(5*x/319-2.5, -2.5*y/221+1.25)
      i = 0
      while (i < N_iteration) and abs(z) < 2:
        i = i + 1
        z = z*z+c 
      rgb = int(255*i/N_iteration)
      if rgb==0:
        col = kandinsky.color(0,255,0)
      elif rgb>0 and rgb<=10:
        col = kandinsky.color(127,255,0)
      elif rgb>11 and rgb<=20:
        col = kandinsky.color(255,255,0)
      elif rgb>21 and rgb<=30:
        col = kandinsky.color(255,127,0)
      elif rgb>31 and rgb<=40:
        col = kandinsky.color(255,0,0)
      elif rgb>41 and rgb<=50:
        col = kandinsky.color(255,0,127)
      elif rgb>51 and rgb<=60:
        col = kandinsky.color(255,0,255)
      elif rgb>61 and rgb<=70:
        col = kandinsky.color(127,0,255)
      elif rgb>71 and rgb<=80:
        col = kandinsky.color(0,0,255)
      elif rgb>81 and rgb<=90:
        col = kandinsky.color(0,127,255)
      elif rgb>91 and rgb<=100:
        col = kandinsky.color(0,255,255)
      elif rgb>101 and rgb<=110:
        col = kandinsky.color('blue')
      elif rgb>111 and rgb<=120:
        col = kandinsky.color('red')
      elif rgb>121 and rgb<=130:
        col = kandinsky.color('green')
      elif rgb>131 and rgb<=140:
        col = kandinsky.color('yellow')
      elif rgb>141 and rgb<=150:
        col = kandinsky.color('brown')
      elif rgb>151 and rgb<=160:
        col = kandinsky.color('black')
      elif rgb>161 and rgb<=170:
        col = kandinsky.color('white')
      elif rgb>171 and rgb<=180:
        col = kandinsky.color('pink')
      elif rgb>181 and rgb<=190:
        col = kandinsky.color('orange')
      elif rgb>191 and rgb<=200:
        col = kandinsky.color('purple')
      elif rgb>201 and rgb<=210:
        col = kandinsky.color('grey')
      elif rgb>211 and rgb<=220:
        col = kandinsky.color('blue')
      elif rgb>221 and rgb<=230:
        col = kandinsky.color('red')
      elif rgb>231 and rgb<=240:
        col = kandinsky.color('green')
      elif rgb>241 and rgb<=250:
        col = kandinsky.color('yellow')
      else:
        col = kandinsky.color(0,255,127)
      kandinsky.set_pixel(x,y,col)

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 cookies policy.