This file contains 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
import scene, ui | |
shadercode_text = ''' | |
// Modified Mandelbrot code from shadertoy.com | |
// https://www.shadertoy.com/view/XdtSRN | |
// used make_color function from ccc (pythonista forum) | |
// https://github.com/cclauss/fractal_hacks/blob/master/cc_mandelbrot.py | |
precision highp float; | |
varying vec2 v_tex_coord; |
This file contains 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
# Sharing pyui file is simplified by the following omz's script. | |
# https://forum.omz-software.com/topic/2905/helper-script-for-embedding-pyui-files-in-single-file-scripts | |
# This may be good enough if users just want to run the script. | |
# But if they want to see or edit the .pyui file, it would be helpful | |
# to generate the .pyui file. This script does this geneartion. | |
# This script extracts the encoded string, decode it and | |
# generate the .pyui file. Like the embedpyui script, | |
# this needs to be added to editor actions (wrench) menu. | |
# |
This file contains 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
# coding: utf-8 | |
import bz2 | |
from base64 import b64decode | |
data = '''\ | |
QlpoOTFBWSZTWf2rpqIAEq7fgFUQUGd/9T/kmYq/79/6YAifD0d2D50GmgESoe4AOgMGop | |
6Jpk00GEaPUHqNDTJtTJkZBoAElJgJpglMUBoAAA0DQAA5piYCNMCMIwAAABMIwEppqaoj | |
QAAABoAD1NAAAEUgQBGJlU8UAAAAAAAClJEEaTTAiIAekB6g0NGgeRH5U4F2UyKh+yh09M | |
vXptst8B8aGUNqGRLsocKGiNsKyWMwMJkQ4cOPKqKXKoR+CijjlhhhgZIOdSl9e1Q/5jjh | |
FREATWyXbHkmIyNeRwI4DOb5L1Mwh+YM0AQML5jKxDXfY1K3V9zYz5ZllqGBrMYxmNFrRm | |
mWUT+2E4EcpGEeD/3s/LauhdZ4hwofD4ee4ceL6sevDEciKPp0lpnNX6kP7fstGzJEpS4Z |
This file contains 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
# coding: utf-8 | |
import scene | |
import ui | |
from PIL import Image as PILImage | |
class MyScene (scene.Scene): | |
def setup(self): | |
self.im = PILImage.open('tunnelswirl.gif') | |
self.mypalette = self.im.getpalette() | |
self.savefile = 'tmp.png' |
This file contains 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
import scene | |
import copy | |
import math | |
import ui | |
class Paddle(scene.ShapeNode): | |
def __init__(self, x, y, parent=None): | |
path = ui.Path.rect(0,0, 40, 200) | |
super(Paddle, self).__init__(path, position=(x, y), fill_color='green', parent=parent) | |
self.touch = None |
This file contains 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
import scene | |
import ui | |
""" | |
Carwash example. | |
Covers: | |
- Waiting for other processes | |
- Resources: Resource |
This file contains 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
import ui | |
images = [ui.Image.named(i) for i in 'Rabbit_Face|Mouse_Face|Cat_Face|Dog_Face|Octopus|Cow_Face'.split('|')] | |
def button_action(sender): | |
def animation(): | |
cv = sender.superview['view1'].subviews[0] | |
w = sender.superview['view1'].width | |
if sender.title == '>': | |
if cv.x > (-(len(images)-1)*w): |
This file contains 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
# coding: utf-8 | |
# code from https://github.com/controversial/ui2/blob/master/ui2/animate.py | |
# code modified for bug in https://forum.omz-software.com/topic/3504/lab-ui-animate-sliding-in-views | |
from copy import copy | |
from objc_util import * | |
# Constants representing easings. See http://apple.co/29FOF5i | |
ANIMATE_EASE_IN = 1 << 16 |
This file contains 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
import ui | |
import sys | |
class TextViewFile(object): | |
def __init__(self, textview): | |
self.textview = textview | |
def write(self, msg): | |
self.textview.text += msg |
OlderNewer