【问题标题】:How to create circle and triangle with specific colour using turtle in python?如何在python中使用乌龟创建具有特定颜色的圆形和三角形?
【发布时间】:2018-02-27 06:26:41
【问题描述】:
import turtle
import math
import random
import os`

player = turtle.Turtle()
player.color("yellow")
player.shape("triangle")
player.penup()
player.speed(0)`

maxGoals = 10
goals = []

for count in range(maxGoals):
    goals.append(turtle.Turtle())
    goals[count].color("red")
    goals[count].shape("circle")
    goals[count].penup()
    goals[count].speed(0)
    goals[count].setposition(random.randint(-290,290),random.randint(-290,290))` 

运行此代码时,我只得到circle's outline in Red colortriangle's outline in Yellow color

我需要circle filled with red colortriangle filled with Blue color。我已经包含了下面的图片:

请帮我解决这个问题

【问题讨论】:

    标签: python python-2.7 turtle-graphics


    【解决方案1】:

    我运行了您提供的代码,并且运行良好。请在不同的机器上尝试相同的代码并提供详细信息,以便如果这是系统特定的问题,如果您提供更多信息,我将能够为您提供帮助。

    我使用 Mac 运行它,python 2.7

    慢跑者

    【讨论】:

    • 是的,你是对的,它适用于 mac。我正在使用Ubuntu 16.10 with python 2.7 linux 操作系统。这里只显示了我在屏幕截图中提到的轮廓。请帮助我解决这个问题。
    【解决方案2】:

    这个问题在SO上已经出现过好几次了,可惜今天早上我只能找到一个:Turtle will not draw angled lines

    答案总是似乎是显卡驱动问题。纠正后,事情开始按预期工作。抱歉,我不能更具体,但这取决于您的系统设置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-13
      • 1970-01-01
      • 1970-01-01
      • 2017-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-08
      相关资源
      最近更新 更多