Why is the shape not getting coloured?

Viewed 43

I dont understand why the shape is not being coloured. ive gone over the code but isnt working..why is that? like what am i missing

import turtle
t = turtle.Turtle()

def draw_quadrilateral(height, width):
    for i in range(2):
        t.forward(width)
        t.left(90)
        t.forward(height)
        t.left(90)

draw_quadrilateral(90, 90)

def fill_shape(color):
    t.end_fill()
    t.fillcolor(color)
    t.begin_fill()

draw_quadrilateral(100, 200)
fill_shape('black') 

def move_turtle(x, y):
    t.penup()
    t.goto(x, y)
    t.pendown()

    move_turtle(20, 50)
    fill_shape('Red')
    draw_quadrilateral(40, 40)

turtle.end_fill()
turtle.hideturtle()
turtle.done()
1 Answers

begin_fill() is used before drawing the shape to be filled.

end_fill() is used after drawing the shape for termination.

import turtle

t = turtle.Turtle()

def draw_quadrilateral(height, width):
    for i in range(2):
        t.forward(width)
        t.left(90)
        t.forward(height)
        t.left(90)

def draw_shape(height, width, color):
    t.fillcolor(color)
    t.begin_fill()
    draw_quadrilateral(height, width)
    t.end_fill()


draw_shape(200, 100, 'red')
Related