begin_fill不填充任何内容

时间:2019-02-25 00:10:08

标签: python python-3.x turtle-graphics

我正在编写一个乌龟程序。我需要使用end_fillfrom turtle import * pensize(180) penup() speed(1000) setpos(-220, -220) pencolor("green") shape(name = "turtle") down() fd(420) left(90) penup() fd(90) left(90) fd(490) right(90) fd(100) right(90) fd(60) down() pencolor("white") fd(450) left(90) penup() fd(100) left(90) fd(490) left(90) fd(40) left(180) fd(40) right(90) fd(40) down() pencolor("orange") fd(450) penup() right(90) fd(100) right(90) fd(225) down() pencolor("blue") pensize(10) circle(50) left(90) penup() fd(20) right(90) pendown() begin_fill("blue") circle(30) end_fill("blue") 使填充变为蓝色。但是,每次我填充它时,它都会填充黑色。如何使形状填充其他任何颜色,例如蓝色?如果您猜到了,这是印度国旗。这是我的代码:

`

 userInput = input("Enter a line of text: ")
 vowels = "aeiouAEIOU"

 for count in userInput:
     x = 9 #there are 10 vowels, from 0 to 9
     while x >= 0:
         if count == vowels[x]:
             print("\n",count)
         x -= 1

 print("\n Done")

` 请回答!! 另外,如果运行此命令,则黑色中间应为蓝色。 PLz帮忙!

2 个答案:

答案 0 :(得分:0)

使用color("blue")

...
color("blue")
begin_fill()
circle(30)
end_fill()

答案 1 :(得分:0)

begin_fill()end_fill()命令不带 color 参数-实际上,它们不带 any 参数。您需要使用color()fillcolor()来完成所需的操作。我已经通过以下修复方法对您的代码进行了重新设计,同时将其缩短了一些乌龟指令。

我还在代码的顶部添加了一个补丁,可将线的末端从圆形变为矩形。我发现使用粗笔绘制标志会有所帮助。这可能会给您留下您需要做的其余图纸带来麻烦:

from turtle import *
import tkinter as _

_.ROUND = _.BUTT

shape(name="turtle")
speed('fastest')
pensize(180)
penup()

pencolor("green")
setpos(-220, -220)
pendown()
forward(450)
penup()

setpos(-220, -20)

pencolor("white")
pendown()
forward(450)
penup()

setpos(-220, 80)

pencolor("orange")
pendown()
forward(450)
penup()

right(90)
forward(100)
right(90)
forward(225)

pencolor("blue")
pensize(10)
pendown()
circle(50)
penup()

left(90)
forward(20)
right(90)

color("blue")
pendown()
begin_fill()
circle(30)
end_fill()

hideturtle()
done()

enter image description here