Skip to content

Instantly share code, notes, and snippets.

jsbain

Block or report user

Report or block jsbain

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View audiounittest2.py
from objc_util import *
from ctypes import *
from coreaudioconstants import *
import time
import numpy as np
''' Adapted from https://www.cocoawithlove.com/2010/10/ios-tone-generator-introduction-to.html
'''
AudioUnitRenderActionFlags=c_uint32
View audiounittest2.py
from objc_util import *
from ctypes import *
from coreaudioconstants import *
import time
import numpy as np
''' Adapted from https://www.cocoawithlove.com/2010/10/ios-tone-generator-introduction-to.html
'''
AudioUnitRenderActionFlags=c_uint32
View iosurface.py
from objc_util import *
from ctypes import *
from contextlib import contextmanager
import ui
import numpy as np
''' define ctypes signatures'''
IOSurfaceCreate=c.IOSurfaceCreate
IOSurfaceCreate.argtypes=[c_void_p]
IOSurfaceCreate.restype=c_void_p
View screenspeedtest.py
import ui, io, Image, matplotlib.image,numpy, timeit
print(__file__)
A=numpy.random.rand(300,300,3)
Au=(255*A).astype('uint8')
B=io.BytesIO()
def p(format='jpeg'):
B.seek(0)
Image.fromarray(Au).save(B,format=format)
return ui.Image.from_data(B.getvalue())
def m(format='jpeg'):
View audiounittest.py
from objc_util import *
from ctypes import *
from coreaudioconstants import *
''' Adapted from https://www.cocoawithlove.com/2010/10/ios-tone-generator-introduction-to.html
'''
AudioUnitRenderActionFlags=c_uint32
OSStatus=c_int32
OSType=c_uint32
@jsbain
jsbain / inputAccessoryExample.py
Created Oct 14, 2018
inputAccessoryExample.py
View inputAccessoryExample.py
# coding: utf-8
'''Creates a custom input accessory view, and attaches it to textfield and textview
this example demonstrates custom text buttons (emoji, etc), and custom actions
'''
from objc_util import *
import ui
'''set up top level view and textfield'''
v=ui.View(frame=[0,0,300,300],bg_color=(.92, .92, .92))
tf=ui.TextField(frame=[10,10,200,30])
View 3dview.py
from scene import *
#import sound
import random
import math
import numpy as np
A = Action
class Shape3D (object):
View navview_utils.py
import ui,console,time
from objc_util import on_main_thread
@on_main_thread
def get_top_view(navigation_view):
'''returns the top (aka visible) view from a navigation view'''
import ctypes
nc= navigation_view.objc_instance.navigationController()
tc=nc.topViewController()
v=tc.view()
return v.pyObject(restype=ctypes.py_object,argtypes=[])
View Untitled_203.py
import ui, random
pyui='''
\n[\n{\n"class":"View",\n"attributes":{\n"background_color":"RGBA(1.000000,1.000000,1.000000,1.000000)",\n"tint_color":"RGBA(0.000000,0.478000,1.000000,1.000000)",\n"enabled":true,\n"border_color":"RGBA(0.000000,0.000000,0.000000,1.000000)",\n"flex":""\n},\n"frame":"{{0,0},{240,240}}",\n"selected":false,\n"nodes":[\n{\n"class":"Button",\n"attributes":{\n"font_size":15,\n"tint_color":"RGBA(1.000000,0.511111,0.266667,1.000000)",\n"title":"Button",\n"name":"button1",\n"class":"Button",\n"frame":"{{80,104},{80,32}}",\n"background_color":"RGBA(1.000000,0.755556,0.633333,1.000000)",\n"uuid":"EBCC1C1F-4705-4F87-A6A1-07C0A50D7116"\n},\n"frame":"{{27,25},{80,87}}",\n"selected":true,\n"nodes":[\n\n]\n}\n]\n}\n]\n
'''
class bgLines(ui.View):
def draw(self): #drawing must happen in draw
self.w = ui.get_screen_size()[0]
self.h = ui.get_screen_size()[1]
self.lines=[]
View turtle2.py
#\input texinfo
# coding: utf-8
# ui-based iOS port of the turtle module (not 100% compatible with standard library
# turtle module, but most things beginners would use should work)
import ui
from math import *
import math
import time
You can’t perform that action at this time.