|
|
|
@ -10,7 +10,7 @@
|
|
|
|
|
import dessiner as ds |
|
|
|
|
import turtle as trt |
|
|
|
|
import random as rd |
|
|
|
|
|
|
|
|
|
trt.bgcolor("lightskyblue") |
|
|
|
|
|
|
|
|
|
# Constantes |
|
|
|
|
|
|
|
|
@ -18,12 +18,13 @@ LARGEUR_IMMEUBLE = 140
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Fonction privées |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def immeuble_aleatoire(numero:int) -> dict: |
|
|
|
|
informations = {} |
|
|
|
|
informations['couleur_facade'] = couleur_aleatoire() |
|
|
|
|
informations['numero'] = numero |
|
|
|
|
informations['etages'] = rd.randint(2,6) |
|
|
|
|
informations['etages'] = rd.randint(2,5) |
|
|
|
|
return informations |
|
|
|
|
|
|
|
|
|
def couleur_aleatoire() -> str: |
|
|
|
@ -36,17 +37,6 @@ def coordonnees_facade(immeuble:dict) -> tuple:
|
|
|
|
|
y_bas = -100 |
|
|
|
|
return (x_gauche, y_bas) |
|
|
|
|
|
|
|
|
|
def coordonees_fenetre(immeuble:dict) -> tuple: |
|
|
|
|
x_gauche, y_bas = coordonnees_facade(immeuble) |
|
|
|
|
x_gauche = x_gauche - 100 |
|
|
|
|
y_bas = y_bas + 20 |
|
|
|
|
return (x_gauche, y_bas) |
|
|
|
|
|
|
|
|
|
def coordonees_fenetre_etage(immeuble:dict) -> tuple: |
|
|
|
|
x_gauche, y_bas = coordonees_fenetre(immeuble) |
|
|
|
|
x_gauche = x_gauche + 45 |
|
|
|
|
return (x_gauche, y_bas) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def dessiner_facade(immeuble:dict) -> None: |
|
|
|
|
# Traduction des données de rue vers dessiner |
|
|
|
@ -63,48 +53,36 @@ def dessiner_facade(immeuble:dict) -> None:
|
|
|
|
|
def dessiner_porte(immeuble:dict) -> None: |
|
|
|
|
# Traduction des données de rue vers dessiner |
|
|
|
|
crayon = {} |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
def dessiner_fenetre(immeuble:dict) -> None: |
|
|
|
|
crayon = {} |
|
|
|
|
crayon['écriture'] = 'white' |
|
|
|
|
crayon['fond'] = 'blue' |
|
|
|
|
crayon['écriture'] = 'black' |
|
|
|
|
crayon['fond'] = 'brown' |
|
|
|
|
crayon['épaisseur'] = 2 |
|
|
|
|
x, y = coordonees_fenetre(immeuble) |
|
|
|
|
cote = 30 |
|
|
|
|
ds.rectangle(cote, cote, crayon, (x,y)) |
|
|
|
|
x, y = coordonnees_facade(immeuble) |
|
|
|
|
position = rd.randint(0,2) |
|
|
|
|
x = x -95 + 42.5*position |
|
|
|
|
y = y |
|
|
|
|
ds.rectangle(55, 30, crayon, (x,y)) |
|
|
|
|
|
|
|
|
|
def dessiner_fenetre_etage(immeuble:dict) -> None: |
|
|
|
|
def dessiner_fenetre(immeuble:dict, etage:int, position:int) -> None: |
|
|
|
|
crayon = {} |
|
|
|
|
crayon['écriture'] = 'white' |
|
|
|
|
crayon['fond'] = 'blue' |
|
|
|
|
crayon['épaisseur'] = 2 |
|
|
|
|
x, y = coordonees_fenetre_etage(immeuble) |
|
|
|
|
x, y = coordonnees_facade(immeuble) |
|
|
|
|
x = x -95 + 42.5*position |
|
|
|
|
y = y + 25 + etage * 80 |
|
|
|
|
cote = 30 |
|
|
|
|
for i in range(2): |
|
|
|
|
ds.rectangle(cote, cote, crayon, (x + i * 45,y)) |
|
|
|
|
v = (x + i * 45,y) |
|
|
|
|
|
|
|
|
|
def dessiner_fenetre_immeuble(immeuble:dict) -> None: |
|
|
|
|
crayon = {} |
|
|
|
|
crayon['écriture'] = 'white' |
|
|
|
|
crayon['fond'] = 'blue' |
|
|
|
|
crayon['épaisseur'] = 2 |
|
|
|
|
x, y = coordonees_fenetre_etage(immeuble) |
|
|
|
|
cote = 30 |
|
|
|
|
for i in range(immeuble['etages']): |
|
|
|
|
x = -200 |
|
|
|
|
y = y + i * 80 |
|
|
|
|
for i in range(3): |
|
|
|
|
ds.rectangle(cote, cote, crayon, (x + i * 45,y)) |
|
|
|
|
ds.rectangle(cote, cote, crayon, (x,y)) |
|
|
|
|
|
|
|
|
|
def dessiner_fenetres(immeuble:dict) -> None: |
|
|
|
|
for etage in range(immeuble['etages']): |
|
|
|
|
for position in range(3): |
|
|
|
|
dessiner_fenetre(immeuble, etage, position) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def dessiner_immeuble(immeuble:dict) -> None: |
|
|
|
|
dessiner_facade(immeuble) |
|
|
|
|
dessiner_fenetres(immeuble) |
|
|
|
|
dessiner_porte(immeuble) |
|
|
|
|
dessiner_fenetre(immeuble) |
|
|
|
|
dessiner_fenetre_etage(immeuble) |
|
|
|
|
dessiner_fenetre_immeuble(immeuble) |
|
|
|
|
# à compléter avec d'autres fonctions pour le reste : toit, fenêtres... |
|
|
|
|
|
|
|
|
|
def dessiner_rue_aleatoire() -> None: |
|
|
|
|