Python Forum
Turtle Graphics Help - Filling each shape in
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Turtle Graphics Help - Filling each shape in
#9
Hi, how can i fill each polygon with a different color? the current code i have only colors the drawings sides, but it doesn't fill the inside.
Thanks!
import turtle
window = turtle.Screen()
window.bgcolor("white")
vlad  = turtle.Turtle()
vlad.speed(300)
vlad.penup()
def drawingpoly() : #Polygon Drawings

    four = 4 # number of sides
    five = 5 # number of sides
    six = 6 # number of sides
    seven = 7 # number of sides
    eight = 8 # number of sides
    nine = 9 # number of sides
    x = -100 # x position
    y = 200 # y position
    vlad.goto(x, y) #move turtle to the coords above (x and y)




    side_length = 150
    angle = 360.0 / four #360 divided by sides
    angle2 = 360.0 / five  # 360 divided by sides
    angle3 = 360.0 / six  # 360 divided by sides
    angle4 = 360.0 / seven  # 360 divided by sides
    angle5 = 360.0 / eight  # 360 divided by sides
    angle6 = 360.0 / nine #360 divided by sides


    for i in range(four): #amount of repeats
        vlad.pencolor("red")
        vlad.begin_fill()
        vlad.pendown()
        vlad.forward(side_length / 2)
        vlad.stamp()  # stamp the turtle symbol
        vlad.forward(side_length / 2)  # move half the distance
        vlad.right(angle)
        vlad.end_fill()
    for i in range(five): #amount of repeats
        vlad.fillcolor("yellow")
        vlad.begin_fill()
        vlad.forward(side_length / 2)
        vlad.stamp()  # stamp the turtle symbol
        vlad.forward(side_length / 2)  # move half the distance
        vlad.right(angle2)
        vlad.end_fill()
    for i in range(six): #amount of repeats
        vlad.begin_fill()
        vlad.forward(side_length / 2)
        vlad.stamp()  # stamp the turtle symbol
        vlad.forward(side_length / 2)  # move half the distance
        vlad.right(angle3)
        vlad.end_fill()
    for i in range(seven): #amount of repeats
        vlad.begin_fill()
        vlad.forward(side_length / 2)
        vlad.stamp()  # stamp the turtle symbol
        vlad.forward(side_length / 2)  # move half the distance
        vlad.right(angle4)
        vlad.end_fill()
    for i in range(eight): #amount of repeats
        vlad.begin_fill()
        vlad.forward(side_length / 2)
        vlad.stamp()  # stamp the turtle symbol
        vlad.forward(side_length / 2)  # move half the distance
        vlad.right(angle5)
        vlad.end_fill()
    for i in range(nine): #amount of repeats
        vlad.begin_fill()
        vlad.forward(side_length)
        vlad.right(angle6)
        vlad.end_fill()
        vlad.penup()
Reply


Messages In This Thread
Turtle Graphics Help - by Nate - Nov-14-2018, 05:45 PM
RE: Turtle Graphics Help - by ichabod801 - Nov-14-2018, 11:14 PM
RE: Turtle Graphics Help - by Nate - Nov-15-2018, 04:39 AM
RE: Turtle Graphics Help - by ichabod801 - Nov-15-2018, 03:07 PM
RE: Turtle Graphics Help - by Nate - Nov-16-2018, 04:21 AM
RE: Turtle Graphics Help - by ichabod801 - Nov-16-2018, 04:26 AM
RE: Turtle Graphics Help - by Nate - Nov-16-2018, 04:53 AM
RE: Turtle Graphics Help - by ichabod801 - Nov-16-2018, 02:56 PM
Turtle Graphics Help - Filling each shape in - by Nate - Nov-26-2018, 10:01 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Project 4 Shape Calculator FreeCodeCamp btownboy 5 2,980 Sep-14-2020, 01:38 AM
Last Post: btownboy
  python idle turtle graphics help jojo 5 4,200 Apr-14-2019, 12:28 PM
Last Post: ichabod801
  Turtle Graphics Card Values in a List Muzz 0 2,438 Apr-11-2019, 12:55 PM
Last Post: Muzz
  why is this not filling my empty list? Siylo 4 3,313 Jan-21-2019, 05:27 PM
Last Post: Siylo
  ValueError: shape mismatch: value array of shape... ulrich48155 2 24,014 Jul-10-2017, 02:17 PM
Last Post: ulrich48155

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020