crepe.py

Created by schraf

Created on January 27, 2022

716 Bytes

Création d’une plaque de cuisson, de la crêpe et de sa cuisson. Bon appétit !


from random import *
from kandinsky import set_pixel
from math import sin,cos,pi

clair = (200,180,120)
fonce = (170,90,20)
noir = (0,0,0)

def cuire(cx,cy,r,p, coul = [fonce,clair]):
  for x in range(-r, r):
    for y in range(-r, r):
      d = x * x + y * y
      if d < r * r:
        coeff = 1.5 * p if d > .9 * r * r else p
        set_pixel(int(cx + x), int(cy + y), coul[0] if random() < coeff else coul[1])

def crepe():
  cuire(160,110,100,.9,[noir,fonce])
  cuire(160,110,90,.3)
  for k in range(200):
    cx, cy, r = randint(-80,80),randint(-80,80), randint(3,10)
    if cx ** 2 + cy ** 2 < 6400: cuire(160 + cx,110 + cy,r,.6)
    cuire(160+90*cos(k/100*pi),110+90*sin(k/100*pi),2,.8)
crepe()