Skip to content

Instantly share code, notes, and snippets.

Last active January 4, 2016 21:49
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Use PIL to draw an image of a diagonal line and then make a Pythonista scene.Layer to display the image.
import Image, ImageDraw, scene
def diagonalLineImage(inLength = 200, inColors = ('blue', 'ivory')):
imageLength = inLength + 100 # the image can be larger than what you draw
theImage ='RGBA', (imageLength, imageLength), inColors[1])
draw = ImageDraw.Draw(theImage)
draw.line((0, 0, inLength, inLength), fill = inColors[0])
del draw
return theImage
class DiagonalLineLayer(scene.Layer):
def __init__(self):
theImage = diagonalLineImage()
theRect = scene.Rect(0, 0, *theImage.size)
super(self.__class__, self).__init__(theRect)
self.image = scene.load_pil_image(theImage)
class DiagonalLineScene(scene.Scene):
def __init__(self):
def setup(self):
self.layer = DiagonalLineLayer()
def draw(self):
scene.background(0.7, 0.7, 0.7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment