nandha kumar
nandha kumar

Reputation: 303

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 colorand the triangle filled with Blue color. I have included the image below:

Here the circle's outline is in red colour and triangle's outline is in Yellow color

Kindly help me to fix this issue

Upvotes: 1

Views: 914

Answers (2)

cdlane
cdlane

Reputation: 41872

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.

Upvotes: 1

joginder singh
joginder singh

Reputation: 177

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 program output

joginder

Upvotes: 1

Related Questions