Python Turtle Code: Peacock Tail

Pubblicato il: 13 febbraio 2022
sul canale di: Basic Python Turtle Art
216
3

A spread-out tail using 3 kinds of feathers. The Python Turtle code uses 2 switches: sw1 for main or primary feather, and sw2 for secondary feathers A and B.

Please feel free to copy and paste the Python Turtle code below. Don't hesitate to ask questions about the code if you have any. Enjoy!
import turtle
scrin = turtle.Screen()
t = turtle.Turtle()
t.pensize(5)
t.speed(4)
t.right(20)
sw1 = 0 #switch: sw1 = 0 for main "feather", sw1 = 1 for secondary ones
sw2 = 0 #secondswitch: sw2 = 0 for secondary "feather" A, = 1 for B
for i in range(23):
t.penup()
t.goto(0, -120)
t.forward(50)
t.pendown()
t.forward(290)
if sw1 == 0: #conditional for main "feather", which has circles at tip of rib
t.right(90)
t.fillcolor("red")
for j in [20, 10]:
t.begin_fill()
t.circle(j)
t.end_fill()
t.fillcolor("yellow")
t.left(100)
sw1 = 1 #sw1 switches to 1 from 0 to avoid successive main "feathers"
else:
if sw2 == 0: #conditional for secondary "feather" A, which has circles at mid rib
t.backward(100)
t.right(90)
t.fillcolor("red")
for j in [20, 10]:
t.begin_fill()
t.circle(j)
t.end_fill()
t.fillcolor("yellow")
t.left(100)
sw1 = 0 #sw1 switches back to 0 after a secondary "feather" is drawn
sw2 = 1 #sw2 switches to 1 from 0 to avoid successive secondary "feathers" A
else: #conditional for secondary "feather" B, which has circles at low rib
t.backward(200)
t.right(90)
t.fillcolor("red")
for j in [20, 10]:
t.begin_fill()
t.circle(j)
t.end_fill()
t.fillcolor("yellow")
t.left(100)
sw1 = 0 #sw1 switches back to 0 after a secondary "feather" is drawn
sw2 = 0 #sw2 switches back to 0 to avoid successive secondary "feathers" B
scrin.exitonclick()


In questa pagina del sito puoi guardare il video online Python Turtle Code: Peacock Tail della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Basic Python Turtle Art 13 febbraio 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 216 volte e gli è piaciuto 3 spettatori. Buona visione!