在 python 海龟中绘制印度国旗脉轮
Drawing a indian flag chakra in python turtlee
我正在使用乌龟和 python 绘制印度国旗。到目前为止,我已经得到了矩形和颜色,但我正在努力使脉轮位于中间。
它有24根辐条,周围是一个封闭的圆圈。有关如何完成此操作的任何提示?
现在这是我的代码:
import turtle
def drawRectangle (t, w, h, c):
t.fillcolor(c)
t.begin_fill()
for i in range(2):
t.forward(h)
t.left(90)
t.forward(w)
t.left(90)
t.end_fill()
def main ():
wn = turtle.Screen()
chloe = turtle.Turtle()
drawRectangle(chloe,50,200, "chartreuse3")
chloe.up()
chloe.goto(0,-100)
chloe.down()
drawRectangle(chloe,50,200, "orange1")
chloe.up()
chloe.goto(100,-25)
chloe.down()
chloe.pencolor("blue4")
for i in range(24):
chloe.forward(20)
chloe.backward(20)
chloe.left(15)
chloe.up()
chloe.goto(300,300)
main()
您可以使用circle
画圆:
chloe.pencolor("blue4")
# draw the spokes
for i in range(24):
chloe.forward(20)
chloe.backward(20)
chloe.left(15)
# raise pen
chloe.up()
# head down
chloe.setheading(270)
# go forward 20
chloe.forward(20)
# reset heading
chloe.setheading(0)
# pen down
chloe.down()
# draw the circle
chloe.circle(20)
import turtle
def drawRectangle (t, l, b, c):
t.fillcolor(c)
t.begin_fill()
for i in range(2):
t.forward(b)
t.left(90)
t.forward(l)
t.left(90)
t.end_fill()
def main ():
wn = turtle.Screen()
india = turtle.Turtle()
drawRectangle(india,50,200, "orange1")
india.up()
india.goto(0,-100)
india.down()
drawRectangle(india,50,200, "green")
india.up()
india.goto(100,-20)
india.down()
india.pencolor("blue3")
for i in range(24):
india.forward(20)
india.backward(20)
india.left(15)
india.up()
india.goto(400,400)
main()
我正在使用乌龟和 python 绘制印度国旗。到目前为止,我已经得到了矩形和颜色,但我正在努力使脉轮位于中间。
它有24根辐条,周围是一个封闭的圆圈。有关如何完成此操作的任何提示?
现在这是我的代码:
import turtle
def drawRectangle (t, w, h, c):
t.fillcolor(c)
t.begin_fill()
for i in range(2):
t.forward(h)
t.left(90)
t.forward(w)
t.left(90)
t.end_fill()
def main ():
wn = turtle.Screen()
chloe = turtle.Turtle()
drawRectangle(chloe,50,200, "chartreuse3")
chloe.up()
chloe.goto(0,-100)
chloe.down()
drawRectangle(chloe,50,200, "orange1")
chloe.up()
chloe.goto(100,-25)
chloe.down()
chloe.pencolor("blue4")
for i in range(24):
chloe.forward(20)
chloe.backward(20)
chloe.left(15)
chloe.up()
chloe.goto(300,300)
main()
您可以使用circle
画圆:
chloe.pencolor("blue4")
# draw the spokes
for i in range(24):
chloe.forward(20)
chloe.backward(20)
chloe.left(15)
# raise pen
chloe.up()
# head down
chloe.setheading(270)
# go forward 20
chloe.forward(20)
# reset heading
chloe.setheading(0)
# pen down
chloe.down()
# draw the circle
chloe.circle(20)
import turtle
def drawRectangle (t, l, b, c):
t.fillcolor(c)
t.begin_fill()
for i in range(2):
t.forward(b)
t.left(90)
t.forward(l)
t.left(90)
t.end_fill()
def main ():
wn = turtle.Screen()
india = turtle.Turtle()
drawRectangle(india,50,200, "orange1")
india.up()
india.goto(0,-100)
india.down()
drawRectangle(india,50,200, "green")
india.up()
india.goto(100,-20)
india.down()
india.pencolor("blue3")
for i in range(24):
india.forward(20)
india.backward(20)
india.left(15)
india.up()
india.goto(400,400)
main()