script_dessin.py

Created by caucaucybu

Created on October 08, 2022

941 Bytes

Ce script permet de dessiner. Touche flèches : direction. Touche XNT : cacher la tortue. Touche VAR : mettre une couleur aléatoire. Touche TOOLBOX : montrer la tortue. Touche BACKSPACE : remet à zéro le dessin. Touche MULTIPLICATION : baisser le stylo. Touche DIVISION : relever le stylo. Touche PLUS : augmenter la taille du tracé. Touche MINUS : réduire la taille du tracé. Touche ANS : lève le stylo si il est baissé, l’abaisse si il est levé (sert à faire du pointillé quand la taille du tracé est de 1).


from ion import *
from kandinsky import *
from turtle import *
from random import *
stop=0
taille=1
showturtle()
while stop!=1:
  pensize(taille)
  if keydown(KEY_UP):
    setheading(90)
    forward(1)
  if keydown(KEY_LEFT):
    setheading(180)
    forward(1)
  if keydown(KEY_RIGHT):
    setheading(0)
    forward(1)
  if keydown(KEY_OK):
    stop=1
  if keydown(KEY_DOWN):
    setheading(-90)
    forward(1)
  if keydown(KEY_XNT):
    hideturtle()
  if keydown(KEY_VAR):
    pencolor(randrange(0,250),randrange(0,250),randrange(0,250))
  if keydown(KEY_TOOLBOX):
    showturtle()
  if keydown(KEY_BACKSPACE):
    reset()
  if keydown(KEY_MULTIPLICATION):
    pendown()
  if keydown(KEY_DIVISION):
    penup()
  if keydown(KEY_PLUS):
    if taille<115:
      taille=taille+1
  if keydown(KEY_MINUS):
    if taille>1:
      taille=taille-1
  if keydown(KEY_ANS):
    if isdown():
      penup()
    else:
      pendown()

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