ausecour.py

Created by lucasleroy012

Created on October 27, 2023

1.31 KB


# Type your text herefrom turtle import *
import kandinsky

def forbackward(d):
  forward(d)
  backward(d)
 
def pf(d=1,gd=-1,nervure=False):
  n=9
  pos=position()
  for j in range(2):
    for k in range(n):
      forward(d)
      right(gd*90/n)
    right(gd*90)
  if nervure:
    right(gd*40)
    forbackward(5*d)
    right(-gd*40)

def fleur(npetales=8,nfeuilles=2,ltige=160,kfeuille=1,c=kandinsky.color(255,255,0)):
  d=ltige/(nfeuilles+1)
  color(0,191,0)
  for j in range(nfeuilles):
    forward(d)
    pf(kfeuille,2*(j%2)-1,True)
  forward(d)
  color((c>>11)<<3,((c>>5)%64)<<2,(c%32)<<3)
  for j in range(npetales):
    pf(kfeuille,-1)
    left(360/npetales)

#example
from math import *

def hsv2color(h,s=1,v=1):
  c=v*s
  x=c*(1-abs((h%120)/60-1))
  m=v-c
  k=int(h/60)
  r=255*(m+x*(k==1 or k==4)+c*(k==5 or k==0))
  g=255*(m+c*(k==1 or k==2)+x*(k==3 or k==0))
  b=255*(m+x*(k==2 or k==5)+c*(k==3 or k==4))
  return kandinsky.color(round(r),round(g),round(b))

def horiz(y,col):
  for x in range(320):
    kandinsky.set_pixel(x,y,col)

for j in range(112):
  horiz(111-j,hsv2color(210,0+1*j/111,1))
  horiz(111+j,hsv2color(30,.1+.9*j/111,.7))

sw=320
sh=222
ymax=sh/2
ymin=ymax-sh+1
xmin=-sw/2
xmax=xmin+sw-1
penup()
goto(0,ymin)
setheading(90)
pendown()
fleur(12,9,ymax-ymin+1-26,3,kandinsky.color(255,255,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 cookies policy.