Bonjour/Bonsoir à tous !
Alors voilà j'ai fait un programme sur Python avec le module turtle dans le but de faire un triangle de Sierpinski
http://fr.wikipedia.org/wiki/Triangle_de_Sierpi%C5%84ski
Cependant il y a un problème, le programme me dit que je ne peut pas soustraire deux "tuple", or je ne vois pas comment corriger cela
Voici le programme en question :
import turtle
def transfo(ch) :
ch=ch.replace("f","f-g+f+g-f")
ch=ch.replace("g","gg")
return ch
def miseAJour(xmin,ymin,xmax,ymax) :
xmin=min(xmin,position()[0])
ymin=min(ymin,position()[1])
xmax=max(xmax,position()[0])
ymax=max(ymax,position()[1])
return (xmin,ymin,xmax,ymax)
def centrageNormalise(xmin,ymin,xmax,ymax) :
xc = ((xmin)+(xmax)) * 0,5
yc = ((ymin)+(ymax)) * 0,5
delta = max(xmax-xmin,ymax-ymin)
delta = delta * 0,5
xmin = xc - delta
ymin = yc - delta
xmax = xc + delta
ymax = yc + delta
turtle.setworldcoordinates(xmin,ymin,xmax,ymax)
def dessine(ch) :
turtle.penup()
turtle.setposition(0,0)
turtle.setheading(0)
xmin, ymin, xmax, ymax =0,0,0,0
for x in ch :
if x=="f" or "g" :
turtle.pendown()
turtle.forward(1)
turtle.penup()
xmin, ymin, xmax, ymax=miseAJour(xmin,ymin,xmax,ymax)
centrageNormalise(xmin,ymin,xmax,ymax)
elif x=="+" :
left(120)
elif x=="-" :
right(120)
turtle.setworldcoordinates(0,0,1,1)
turtle.speed(0)
ch=input("entrez votre chaîne : ")
n=int(input("nombre de transformations : "))
for k in range(n) :
ch=transfo(ch)
dessine(ch)
turtle.hideturtle()
turtle.mainloop()
Est-ce que quelqu'un pourrait m'aider ?