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
# Zen | |
# | |
# Prints the Zen of Python with a color gradient. | |
# This demonstrates the use of the console module to set | |
# the output's font and color. | |
import console | |
import sys | |
import codecs | |
from colorsys import hsv_to_rgb |
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
# Stopwatch | |
# | |
# A simple stopwatch that demonstrates the scene module's text | |
# drawing capabilities. | |
from scene import * | |
from time import time | |
from math import modf | |
from itertools import chain | |
import string |
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
# Sketch | |
# A very simple drawing 'app' that demonstrates | |
# custom views and saving images to the camera roll. | |
import ui | |
import photos | |
import console | |
# The PathView class is responsible for tracking | |
# touches and drawing the current stroke. |
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
# Lottery Number Generator | |
from random import choice | |
import console | |
#Helper function to input a number within a given range: | |
def input_number(prompt, min_value, max_value): | |
value = None | |
while value is None: | |
try: |
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
# Function Plotter | |
import canvas | |
import console | |
from math import sin, cos, pi | |
def draw_grid(min_x, max_x, min_y, max_y): | |
w, h = canvas.get_size() | |
scale_x = w / (max_x - min_x) | |
scale_y = h / (max_y - min_y) |
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
# Piano | |
# | |
# A simple multi-touch piano. | |
from scene import * | |
import sound | |
from itertools import chain | |
class Key (object): | |
def __init__(self, frame): |
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
# Particles | |
# | |
# Create colorful bubbles by moving your fingers. | |
from scene import * | |
from random import random | |
from colorsys import hsv_to_rgb | |
class Particle (object): | |
def __init__(self, location): |
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
# MPL Plot | |
# A simple demo of using matplotlib in Pythonista. | |
import console | |
console.clear() | |
print 'Generating plot... (this may take a little while)' | |
import numpy | |
import matplotlib.pyplot as plt | |
import math |
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
# Markdown Conversion | |
# | |
# This script demonstrates how you can convert Markdown documents | |
# to HTML and view the results in the built-in browser. | |
import os, tempfile, codecs | |
import console, clipboard, webbrowser | |
from markdown2 import markdown | |
DEMO = ''' |
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
# Image Warp | |
# | |
# Demonstrates an interesting use of the image_quad function | |
# to distort an image based on touch. | |
from scene import * | |
from math import sqrt, sin, pi, floor | |
import Image | |
M = 16 # number of vert. and horiz. quads in the mesh (16*16=256) |
NewerOlder