Skip to content

Instantly share code, notes, and snippets.

@SpaceVoyager
Created June 13, 2015 20:47
Show Gist options
  • Save SpaceVoyager/e2b6c731c9597ea98bcd to your computer and use it in GitHub Desktop.
Save SpaceVoyager/e2b6c731c9597ea98bcd to your computer and use it in GitHub Desktop.
fathers day.py
# Example father's day card with animation and sound
import canvas
import speech
from time import sleep
sleepfor = 0.1 # the number of seconds to sleep for
canvas.set_size(1000,600)
canvas.draw_image('_family', 0, 0, 1000, 600)
# here 1000 is the width of the photo, 600 is the height, same as the canvas size.
# So the photo will fill the whole canvas.
# This loop draws the 4 hearts on the left
for i in range(4):
canvas.draw_image('Heart_Sparkling', 10, 150*i)
sleep(sleepfor)
# This loop draws the 5 hearts at the top
for i in range(5):
canvas.draw_image('Heart_Sparkling', 140*i+150, 450)
sleep(sleepfor)
# This loop draws the 4 hearts on the right
# Note the use of the reversed() function. It reverses the order of the list of
# numbers generated by range(4). This is to make the hearts to appear from
# top to bottom
for i in reversed(range(4)):
canvas.draw_image('Heart_Sparkling', 850, 150*i)
sleep(sleepfor)
# This loop draws the 5 hearts at the bottom
# Also note the use of reversed()
for i in reversed(range(5)):
canvas.draw_image('Heart_Sparkling', 140*i+150, 0)
sleep(sleepfor)
# Finally we draw the greeting text and let iPad speak it out
canvas.set_fill_color(1,1,1 )
text = "Happy Father's Day!"
size = 110
fnt = 'PartyLetPlain'
canvas.draw_text(text, 150, 200, fnt, size)
speech.say(text, 'en-US', 0.2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment