請問各位有人知道怎么實作嗎,turtle畫圖的時候能不能把一個多邊形作為整體進行移動,就比如說我現在畫了一個正方形在螢屏中心,我現在想把它整體移動到右上角,而不是讓這個圖形消失,然后在右上角重新畫一個。把這個圖形整體移動到右上角那么就會有一個平緩的移動影片程序,這才是動態的。
uj5u.com熱心網友回復:
不太能實作吧,想到的辦法只能快速重繪uj5u.com熱心網友回復:
s = turtle.Shape("compound")poly1 = ((0,0),(100,-5),(0,30),(-100,-5))
s.addcomponent(poly1, "red", "blue")
poly2 = ((0,0),(100,-10),(-100,-10))
s.addcomponent(poly2, "blue", "red")
turtle.register_shape("myshape", s)
time.sleep(0.5)
turtle.penup()
turtle.fd(100)
#放大因子
turtle.shapesize(2,2)
turtle.shape("circle")
turtle.shapesize(4,4)
turtle.shape("circle")
turtle.shape("myshape")
time.sleep(0.5)
turtle.goto(-100,100)
turtle.shape("circle")
time.sleep(0.5)
turtle.shape("myshape")
time.sleep(0.5)
turtle.goto(200,-200)
turtle.shape("circle")
time.sleep(0.5)
turtle.shape("myshape")
time.sleep(5)
是可以的,用一個定義就可以
uj5u.com熱心網友回復:
for i in range(20,200,1):turtle.goto(i,i)
turtle.shape("myshape")
這樣更平滑
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/89386.html
