Custom Search

Python: Ellipses

An 'ellipse' is called an 'oval shape' by non-mathematicians. To draw one we need to link two arcs or different radii and then duplicate them to complete the shape.

This program draws a series of overlapping ellipses... each quarter section is in a different colour so you can see what is going on more easily.... and they make a pretty pattern - like a flower!

import turtle

a=0

radius=50

#Set up screen

screen=turtle.Screen()

screen.setup(550,500)

screen.bgpic("background.png")

screen.addshape("FuzzlePINK.png")

#Set Fuzzle as turtle

fuzzle = turtle.Turtle("FuzzlePINK.png")

fuzzle.shape("FuzzlePINK.png")

fuzzle.width(5)#set width of drawn line

fuzzle.up()

fuzzle.goto(0,0)#set position of the turtle at centre of screen

fuzzle.down()

# Define a method to draw ellipse - so we can call on it throughout the program

def drawEllipse(radius): # radius is the radius of flattest arc

for count in range(2):

fuzzle.circle(radius,90) )#This draws an arc that is a quarter of a circle radius 'r'
fuzzle.color("green")

fuzzle.circle((radius//2),90) )#This draws an arc that is a quarter of a circle half the radius of the green one - radius 'r//2'
fuzzle.color("purple")

# Main program

while a<360:

fuzzle.seth(-45) # tilt the starting orientation of the Turtle to -45 (same as 315)

drawEllipse(50)# calling the drawEllipse method

a=a+45

fuzzle.seth(90)#Make the Fuzzle upright to finish

 

Here we go.... enjoy!