Last active
September 2, 2017 04:25
-
-
Save ramachandrajr/00ae9310bcb547a858a164a10b65c2f2 to your computer and use it in GitHub Desktop.
Script draws Olympoic logo. Uses a built in python module called turtle to draw shapes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from turtle import Turtle | |
def create_circle( turtle_object, coordinates, color, radius ): | |
"""Creates a circle with **coordinates** as start point.""" | |
# Pull up the pen first. | |
turtle_object.penup() | |
# Go to initial coordinates. | |
turtle_object.goto(coordinates[0], coordinates[1]); | |
# Pendown to start drawing. | |
turtle_object.pendown(); | |
# Use this color. | |
turtle_object.color(color) | |
# with this radius. | |
turtle_object.circle(radius); | |
##################### MAIN ##################### | |
# Create new **Turtle** object. | |
# Fans of harry potter movies can go crazy now | |
myrtle = Turtle() | |
# Set width for fat lines. | |
myrtle.width(25) | |
# Olympic symbol start point. | |
start_x = -200 | |
start_y = 0 | |
# Olympic ring colors. | |
colors = ["blue","yellow","black","green","red"] | |
# Circle radius. | |
RADIUS = 60 | |
# Draw now. | |
for color in colors: | |
create_circle(myrtle, [start_x, start_y], color, RADIUS) | |
if (start_y == 0): | |
start_y = -50 | |
else: | |
start_y = 0 | |
start_x += 90 | |
# Hide turtle / cursor. | |
myrtle.hideturtle(); | |
# keep window open | |
myrtle.getscreen()._root.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment