# ############################################################### # Paysage dessiné en utilisant le module Turtle de Python # Juin 2026 # nsi.gecif.net # ############################################################### import turtle # -------------------------------------------------- # Fenêtre # -------------------------------------------------- screen = turtle.Screen() screen.setup(800, 600) screen.title("Paysage Turtle - nsi.gecif.net") screen.bgcolor("skyblue") screen.tracer(0) t = turtle.Turtle() t.speed(0) t.hideturtle() # -------------------------------------------------- # Outils # -------------------------------------------------- def rectangle(x, y, w, h, color): t.penup() t.goto(x, y) t.setheading(0) t.color(color) t.begin_fill() t.pendown() for _ in range(2): t.forward(w) t.left(90) t.forward(h) t.left(90) t.end_fill() def circle_center(x, y, r, color): t.penup() t.goto(x, y - r) t.color(color) t.begin_fill() t.pendown() t.circle(r) t.end_fill() def polygon(points, color): t.penup() t.goto(points[0]) t.color(color) t.begin_fill() t.pendown() for p in points[1:]: t.goto(p) t.goto(points[0]) t.end_fill() # -------------------------------------------------- # Soleil # -------------------------------------------------- def soleil(x, y): circle_center(x, y, 30, "gold") t.color("gold") t.pensize(2) for angle in range(0, 360, 30): t.penup() t.goto(x, y) t.setheading(angle) t.forward(40) t.pendown() t.forward(15) # -------------------------------------------------- # Nuage # -------------------------------------------------- def nuage(x, y): circle_center(x, y, 15, "white") circle_center(x + 15, y + 5, 18, "white") circle_center(x + 35, y, 15, "white") circle_center(x + 10, y - 8, 15, "white") # -------------------------------------------------- # Maison # -------------------------------------------------- def maison(x, y): rectangle(x, y, 120, 90, "#D2B48C") polygon([ (x - 10, y + 90), (x + 60, y + 150), (x + 130, y + 90) ], "brown") rectangle(x + 45, y, 30, 50, "saddlebrown") rectangle(x + 15, y + 45, 25, 25, "lightblue") rectangle(x + 80, y + 45, 25, 25, "lightblue") # -------------------------------------------------- # Arbre # -------------------------------------------------- def arbre(x, y): rectangle(x - 8, y, 16, 70, "sienna") circle_center(x, y + 90, 25, "forestgreen") circle_center(x - 20, y + 75, 20, "forestgreen") circle_center(x + 20, y + 75, 20, "forestgreen") # -------------------------------------------------- # Immeuble # -------------------------------------------------- def immeuble(x, y): rectangle(x, y, 80, 180, "lightgray") for r in range(5): for c in range(3): rectangle( x + 10 + c * 22, y + 15 + r * 32, 12, 18, "lightyellow" ) # -------------------------------------------------- # Voiture # -------------------------------------------------- def voiture(x, y): rectangle(x, y, 100, 25, "red") polygon([ (x + 20, y + 25), (x + 35, y + 50), (x + 70, y + 50), (x + 85, y + 25) ], "red") circle_center(x + 25, y, 12, "black") circle_center(x + 75, y, 12, "black") # -------------------------------------------------- # Personnage # -------------------------------------------------- def personnage(x, y): circle_center(x, y + 55, 12, "#FFDAB9") t.color("black") t.pensize(2) t.penup() t.goto(x, y + 43) t.pendown() t.goto(x, y) t.goto(x - 15, y + 20) t.penup() t.goto(x, y + 20) t.pendown() t.goto(x + 15, y + 20) t.penup() t.goto(x, y) t.pendown() t.goto(x - 12, y - 20) t.penup() t.goto(x, y) t.pendown() t.goto(x + 12, y - 20) # -------------------------------------------------- # Fleur # -------------------------------------------------- def fleur(x, y): circle_center(x - 4, y, 4, "pink") circle_center(x + 4, y, 4, "pink") circle_center(x, y + 4, 4, "pink") circle_center(x, y - 4, 4, "pink") circle_center(x, y, 3, "yellow") t.color("green") t.penup() t.goto(x, y - 3) t.pendown() t.goto(x, y - 20) # -------------------------------------------------- # Oiseau # -------------------------------------------------- def oiseau(x, y): t.color("black") t.pensize(2) t.penup() t.goto(x, y) t.setheading(45) t.pendown() t.circle(10, 90) t.penup() t.goto(x + 14, y) t.setheading(135) t.pendown() t.circle(10, 90) # -------------------------------------------------- # Feu tricolore # -------------------------------------------------- def feu(x, y): rectangle(x, y, 8, 70, "black") rectangle(x - 12, y + 70, 32, 60, "black") circle_center(x + 4, y + 115, 5, "red") circle_center(x + 4, y + 95, 5, "yellow") circle_center(x + 4, y + 75, 5, "green") # -------------------------------------------------- # Décor # -------------------------------------------------- # sol rectangle(-400, -100, 800, 250, "lightgreen") # route rectangle(-400, -250, 800, 80, "gray") # lignes route for x in range(-380, 400, 80): rectangle(x, -215, 40, 5, "white") # soleil soleil(300, 220) # nuages nuage(-280, 200) nuage(-80, 240) nuage(120, 190) # maison maison(-340, -100) # arbre arbre(-160, -100) # immeuble immeuble(180, -100) # voiture voiture(-30, -200) # personnage personnage(80, -100) # feu tricolore feu(320, -170) # fleurs for x in [-240, -220, -200, -180]: fleur(x, -120) # oiseaux oiseau(-120, 160) oiseau(20, 190) oiseau(100, 150) screen.update() turtle.done()