# ############################################################### # 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 avancé 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, c): t.penup() t.goto(x, y) t.setheading(0) t.color(c) 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 cercle(x, y, r, c): t.penup() t.goto(x, y - r) t.color(c) t.begin_fill() t.pendown() t.circle(r) t.end_fill() def poly(points, c): t.penup() t.goto(points[0]) t.color(c) 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): cercle(x, y, 30, "gold") # ================================================== # NUAGE # ================================================== def nuage(x, y): cercle(x, y, 15, "white") cercle(x + 18, y + 5, 18, "white") cercle(x + 36, y, 15, "white") # ================================================== # MAISON DETAILLEE # ================================================== def maison(x, y): # base rectangle(x, y, 120, 90, "#D9B38C") # toit poly([ (x - 10, y + 90), (x + 60, y + 155), (x + 130, y + 90) ], "#8B3A3A") # cheminée rectangle(x + 95, y + 110, 15, 35, "#8B0000") # fumée cercle(x + 102, y + 155, 6, "lightgray") cercle(x + 110, y + 170, 8, "lightgray") cercle(x + 120, y + 190, 10, "lightgray") # porte rectangle(x + 45, y, 30, 55, "#5A3A22") cercle(x + 70, y + 25, 2, "gold") # fenêtres rectangle(x + 15, y + 45, 25, 25, "white") rectangle(x + 80, y + 45, 25, 25, "white") # ================================================== # ARBRE # ================================================== def arbre(x, y): rectangle(x - 6, y, 12, 60, "sienna") cercle(x, y + 85, 22, "forestgreen") cercle(x - 18, y + 70, 18, "forestgreen") cercle(x + 18, y + 70, 18, "forestgreen") # ================================================== # VOITURE AVANCEE # ================================================== def voiture(x, y): # corps rectangle(x, y, 100, 22, "red") # cabine poly([ (x + 15, y + 22), (x + 30, y + 48), (x + 70, y + 48), (x + 85, y + 22) ], "red") # vitre poly([ (x + 35, y + 25), (x + 45, y + 42), (x + 65, y + 42), (x + 75, y + 25) ], "lightblue") # roues cercle(x + 25, y, 11, "black") cercle(x + 75, y, 11, "black") cercle(x + 25, y, 5, "gray") cercle(x + 75, y, 5, "gray") # ================================================== # IMMEUBLE # ================================================== def immeuble(x, y): rectangle(x, y, 80, 160, "lightgray") for i in range(4): for j in range(3): rectangle(x + 10 + j*20, y + 15 + i*30, 10, 15, "lightyellow") # ================================================== # PERSONNAGE # ================================================== def personnage(x, y, e=1): cercle(x, y + 55*e, 10*e, "#FFDAB9") t.color("black") t.pensize(2) t.penup() t.goto(x, y + 45*e) t.pendown() t.goto(x, y + 10*e) t.goto(x - 15*e, y + 30*e) t.penup() t.goto(x, y + 30*e) t.pendown() t.goto(x + 15*e, y + 30*e) t.penup() t.goto(x, y + 10*e) t.pendown() t.goto(x - 12*e, y - 20*e) t.penup() t.goto(x, y + 10*e) t.pendown() t.goto(x + 12*e, y - 20*e) # ================================================== # FLEUR AMELIOREE # ================================================== def fleur(x, y): cercle(x, y + 4, 4, "pink") cercle(x, y - 4, 4, "pink") cercle(x + 4, y, 4, "pink") cercle(x - 4, y, 4, "pink") cercle(x, y, 3, "yellow") # tige t.color("green") t.pensize(2) t.penup() t.goto(x, y - 3) t.pendown() t.goto(x, y - 25) # ================================================== # 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) # ================================================== # DECOR # ================================================== # sol rectangle(-400, -100, 800, 250, "lightgreen") # route rectangle(-400, -250, 800, 80, "gray") # lignes route for i in range(-380, 400, 60): rectangle(i, -215, 30, 5, "white") # soleil + nuages soleil(280, 220) nuage(-250, 200) nuage(-50, 240) nuage(120, 200) # structures maison(-330, -100) arbre(-140, -100) immeuble(180, -100) # voiture voiture(-50, -200) # personnages (groupe) personnage(30, -100, 1) personnage(60, -100, 0.9) personnage(90, -100, 0.8) personnage(120, -100, 1.1) # fleurs (champ) for x in range(-300, -180, 20): fleur(x, -120) # oiseaux oiseau(-120, 160) oiseau(20, 190) oiseau(100, 150) screen.update() turtle.done()