I’m playing around with displaying a photo from the photo library in a very simple script; however, I’m doing something wrong: where the image should be, it displays white in the shape that the image ought to be:
from scene import *
import photos
class MyScene(Scene):
def __init__(self, mapimage):
mapimage2 = mapimage.convert('RGBA')
self.mapimage = load_pil_image(mapimage2)
def draw(self):
# This will be called for every frame
background(1, 1, .5)
fill(1, 0, 0)
image(self.mapimage, 0, 0)
# Draw a red circle for every finger that touches the screen:
for touch in self.touches.values():
ellipse(touch.location.x - 50, touch.location.y - 50, 100, 100)
mapimage = photos.pick_image(show_albums=True)
if mapimage:
scene = MyScene(mapimage)
run(scene, frame_interval=1)
else:
print 'Canceled or invalid image.'
Touching the screen drags one or more red circles around, but the image doesn’t appear.