fern.py

Created by apocaliips

Created on September 22, 2020

580 Bytes


from random import *
from kandinsky import *

# Lancer par exemple fern(200000)

def fern(n):
  color=(250,23,25)
  x, y = 0,0
  for _ in range(n):
    if random()<0.01:
      nx= 0
      ny = 0.16 * y
    elif random()<0.86:
      nx = 0.85 * x + 0.04 * y
      ny = -0.04 * x + 0.85 * y + 1.6
    elif random()<0.93:  
      nx = 0.2 * x - 0.26 * y
      ny = 0.23 * x + 0.22 * y + 1.6
    else:
      nx = -0.15 * x + 0.28 * y
      ny = 0.26 * x + 0.24 * y + 0.44
    x = nx
    y = ny
    set_pixel(int((30*x+143)*0.8+45),int((-24*y+240)*0.8+20),color(130,80,50))