Skip to content

Instantly share code, notes, and snippets.

@jsbain
jsbain / mapscene.py
Last active Aug 18, 2020
mapscene.py
View mapscene.py
from scene import *
import sound
import random
import math
A = Action
mapsprites=['plc:Brown_Block','plc:Dirt_Block','plc:Grass_Block','plc:Plain_Block',]
def choose_random_node():
tx=random.choice(mapsprites)
sn=SpriteNode(tx)
View simple_recorder.py
import sound,ui
from sound import Recorder
from sound import Player
sound.set_volume(1)
filename='4.m4a' #could have this come from a textfield in the ui...
play_image=ui.Image('iob:play_256')
stop_image=ui.Image('iob:stop_256')
record_image=ui.Image('iob:ios7_circle_filled_256')
View simple_recorder.py
import sound,ui
from sound import Recorder
from sound import Player
sound.set_volume(1)
filename='4.m4a' #could have this come from a textfield in the ui...
play_image=ui.Image('iob:play_256')
stop_image=ui.Image('iob:stop_256')
record_image=ui.Image('iob:ios7_circle_filled_256')
View detector.py
# coding: utf-8
# based on Cethric's image capture gist....
FRAME_PROC_INTERVAL=15 #num frames to skip. 1=go as fast as possible, 5=every fifth frame
import ui
from objc_util import *
import ctypes
from objc_util import autoreleasepool
AVCaptureDevice = ObjCClass('AVCaptureDevice')
AVCaptureDeviceInput = ObjCClass('AVCaptureDeviceInput')
AVCaptureVideoDataOutput = ObjCClass('AVCaptureVideoDataOutput')
View customMenuItem.py
from objc_util import *
from objc_hacks import swizzle # github.com/jsbain/objc_hacks.git
NSNotificationCenter=ObjCClass('NSNotificationCenter')
class PYUIMenuItem(object):
'''Base class representing a uimenuitem, which can be added to the manager.
Each item must have a title string, a selector name, and an action callback.
Must define subclasses with __selector__ field, __title__ string
Action callback must be of form
View customMenuItem.py
from objc_util import *
from objc_hacks import swizzle # github.com/jsbain/objc_hacks.git
NSNotificationCenter=ObjCClass('NSNotificationCenter')
class PYUIMenuItem(object):
'''Base class representing a uimenuitem, which can be added to the manager.
Each item must have a title string, a selector name, and an action callback.
Must define subclasses with __selector__ field, __title__ string
Action callback must be of form
View customMenuItem.py
from objc_util import *
from objc_hacks import swizzle # github.com/jsbain/objc_hacks.git
NSNotificationCenter=ObjCClass('NSNotificationCenter')
class PYUIMenuItem(object):
'''Base class representing a uimenuitem, which can be added to the manager.
Each item must have a title string, a selector name, and an action callback.
Must define subclasses with __selector__ field, __title__ string
Action callback must be of form
View Untitled_20.py
from scene import *
from math import floor
class SceneTimers(Scene):
def setup(self):
t1=LabelNode()
t2=LabelNode()
t3=LabelNode()
View plotView.py
import ui
import numpy as np
W=1024
import time
from objc_util import *
CAShapeLayer=ObjCClass('CAShapeLayer')
View audioengine.py
from objc_util import *
AVAudioEngine = ObjCClass('AVAudioEngine').alloc().init()
AVAudioSession = ObjCClass('AVAudioSession')
AVAudioRecorder = ObjCClass('AVAudioRecorder')
shared_session = AVAudioSession.sharedInstance()
category_set= shared_session.setCategory_withOptions_error_(
ns('AVAudioSessionCategoryRecord'),
0x2, #duckothers
None)
You can’t perform that action at this time.