turtle_prof_001.py

Created by niz-moussatat

Created on June 28, 2022

260 Bytes

Un premier exemple avec turtle.

Ici une simple rosace. Noter la commande color(r,g,b) à la ligne 10, qui permet de définir la couleur en mélangeant 3 teintes : rouge+vert+bleu. Les teintes sont des nombres entiers compris entre 0 et 255.


# Premier exemple
from turtle import * 
penup()
pas = 40
goto(0,0)
setheading(0) 
pendown()
width(3)
for i in range(25) :
  color(255-10*i,10*pos()[0],10*i)
  forward(pas)
  left(90)
  forward( 2*pas )
  goto(0,0)
  pas = pas -1 
penup()

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.