Comment Faire Un Drapeau Sur Python
Turtle est un module intégré à Python. Il offre:
- Dessin à l'adjutant d'un écran (carton).
- Turtle (stylo).
Pour dessiner quelque chose sur l'écran, nous devons déplacer la turtle (stylo), et cascade déplacer la turtle, il existe des fonctions telles que forward(), opposite(), etc.
Prérequis : Notions de base sur la programmation des turtles
Dessinez un arc-en-ciel à l'aide de graphiques de turtle
Dans cette section, nous verrons comment dessiner un arc-en-ciel de deux manières différentes à fifty'aide de Turtle Graphics.
Approcher:
- Importer une turtle.
- Définir l'écran
- Créer un objet turtle
- Définir les couleurs utilisées pour le dessin
- Boucle pour dessiner des demi-cercles orientés à 180 degrés.
Exemple ane:
python3
# Import turtle package import turtle   # Creating a turtle screen object sc = turtle.Screen()   # Creating a turtle object(pen) pen = turtle.Turtle()   # Defining a method to form a semicircle # with a dynamic radius and color def semi_circle(col, rad, val):       # Set the fill colour of the semicircle     pen.colour(col)       # Draw a circle     pen.circle(rad, -180)       # Move the turtle to air     pen.upwardly()       # Movement the turtle to a given position     pen.setpos(val, 0)       # Move the turtle to the ground     pen.down()       pen.right(180)     # Set the colors for drawing col = ['violet', 'indigo', 'blue',        'greenish', 'xanthous', 'orange', 'red']   # Setup the screen features sc.setup(600, 600)   # Set the screen color to black sc.bgcolor('blackness')   # Setup the turtle features pen.right(90) pen.width(ten) pen.speed(vii)   # Loop to draw seven semicircles for i in range(7):     semi_circle(col[i], 10*(       i + viii), -10*(i + one))   # Hide the turtle pen.hideturtle()                              Production:
                 
              
Exemple 2 :
Python3
import turtle   mypen= turtle.Turtle() mypen.shape('turtle') mypen.speed(10)   window= turtle.Screen() window.bgcolor('white') rainbow= ['red','orange','yellow','green','blue','indigo','violet'] size= 180 mypen.penup() mypen.goto(0,-180) for color in rainbow:     mypen.color(color)     mypen.fillcolor(color)     mypen.begin_fill()     mypen.circumvolve(size)     mypen.end_fill()     size-=xx   turtle.washed()                              Production:
Mail service automatically translated
Article written by deepanshu_rustagi and translated by Acervo Lima. The original can be accessed here. Licence: CCBY-SA
Comment Faire Un Drapeau Sur Python,
Source: https://fr.acervolima.com/dessiner-un-arc-en-ciel-a-laide-de-graphiques-de-tortues-en-python/
Posted by: farrelladlyinit.blogspot.com

0 Response to "Comment Faire Un Drapeau Sur Python"
Post a Comment