Skip to content

Instantly share code, notes, and snippets.

@cclauss
Last active December 23, 2015 13:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cclauss/6642429 to your computer and use it in GitHub Desktop.
Save cclauss/6642429 to your computer and use it in GitHub Desktop.
Display the clipboard text at full screen resolution... Show a message to your friends... Show the taxi driver your desired address... Have fun.
# Display the current clipboard text in full screen mode
import clipboard, console, scene
clipText = clipboard.get()
if not clipText:
clipText = """Hang up your cellphone and drive your car!!!"""
zclipText = """Please take me home..."""
class MyScene(scene.Scene):
def setup(self):
(imageName, imageSize) = self.getImageNameAndSize()
theRect = scene.Rect(0, 0, *imageSize)
theRect.center(self.bounds.center())
print(theRect), ; print(self.bounds)
self.add_layer(scene.Layer(theRect))
self.root_layer.image = imageName
def getImageNameAndSize(self):
for fontSize in xrange(256, 31, -32):
(imageName, imageSize) = scene.render_text(clipText, font_size=fontSize)
print(fontSize), ; print(imageSize), ; print(self.bounds)
if scene.Point(*imageSize) in self.bounds:
return (imageName, imageSize)
scene.unload_image(imageName)
return scene.render_text(clipText, font_size=12)
def draw(self):
#scene.background(0, 0, 0)
self.root_layer.update(self.dt)
self.root_layer.draw()
def touch_began(self, touch): pass
def touch_moved(self, touch): pass
def touch_ended(self, touch): pass
scene.run(MyScene(), orientation=scene.LANDSCAPE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment