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

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