简体   繁体   中英

How to create circle and triangle with specific colour using turtle in python?

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))` 

When run this code i am getting only the circle's outline in Red color and the triangle's outline in Yellow color

I need the circle filled with red color and the triangle filled with Blue color . I have included the image below:

这里的圆圈轮廓是红色,三角形的轮廓是黄色

Kindly help me to fix this issue

I ran the code provided by you and it is working just fine. Please try the same code on the different machine and provide details so that if this is a system specific problem, I'll be able to help you if you provide moreinformation.

I ran it using a mac, python 2.7 python程序输出

joginder

This issue has come up several times on SO, but unfortunately, I can only locate one this morning: Turtle will not draw angled lines

The answer always seems to be that it's a graphics driver issue. Once corrected, things start working as expected. Sorry I can't be more specific but it depends on your system's setup.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM