def __init__(self, config): self.shape_type_def = {0: 'Null Shape',1: 'Point', 3: 'PolyLine', 5: 'Polygon', 8: 'MultiPoint', 11: 'PointZ', 13: 'PolyLineZ', 15: 'PolygonZ', 18: 'MultiPointZ', 21: 'PointM', 23: 'PolyLineM', 25: 'PolygonM', 28: 'MultiPointM', 31: 'MultiPatch'} #create an image depending on the screen size scr = ui.get_screen_size() * scene.get_screen_scale() self.scr_width = scr[0] self.scr_height = scr[1] - 64.0 #title bar = 64px if len(config) < 5: print 'Error: You need at least 5 parameter (xdelta, ydelta, background color, shape file, shape color)' sys.exit() self.xdelta = config[0] self.ydelta = config[1] self.bgcolor = config[2] self.pixel = 0 self.imagebuffer = None self.drawbuffer = None self.linewidth = 1 self.data = [] for i in range(3, len(config), 2): self.read_file(config[i]) self.color = config[i+1] self.convert_data(config[i]) self.imagebuffer.show()
def scale_if_retina(path, scale=None, check_exist=True): if scale is None: scale = scene.get_screen_scale() if scale > 1: spath, ext = os.path.splitext(path) spath += '@2x' + ext if not check_exist or os.path.exists(spath): return spath return path
def __init__(self,button_height): self.button_height = button_height self.touch_enabled = False self.image = None self.img_width = None self.img_height = None self.img_landscape = None self.img_portrait = None self.scr_scale = scene.get_screen_scale() self.ratio = 1.0
def __init__(self, text, img, picsize): self.text = text self.textPosition = [0, 0] self.fontnr = 0 # Helvetica self.colornr = 3 # red self.fontsize = 48.0 # 48 point self.img = img.convert('RGBA') self.scale = scene.get_screen_scale() img = None self.picsize = picsize
def __init__(self, button_height): self.button_height = button_height self.touch_enabled = False self.image = None self.img_width = None self.img_height = None self.img_landscape = None self.img_portrait = None self.scr_scale = scene.get_screen_scale() self.ratio = 1.0
def pythonista_info(): # 2.0.1 (201000) plist = plistlib.readPlist(os.path.abspath(os.path.join(sys.executable, '..', 'Info.plist'))) ios_ver, _, machine_model = platform.mac_ver() return dict( pythonista_ver_str = plist['CFBundleShortVersionString'], pythonista_ver_num = plist['CFBundleVersion'], ios_ver_str = ios_ver, screen_resoultion = scene.get_screen_size(), screen_scale = scene.get_screen_scale(), machine_architecture = platform.architecture()[0], machine_model = machine_model, )
def __init__(self): self.view = ui.load_view('PhotoTextV2') self.set_button_actions() self.view.present('full_screen') img = photos.pick_image() if img: console.hud_alert('Please wait...') scale = scene.get_screen_scale() #print str(scale) picsize = scene.Size(*img.size) width = picsize[0] / scale height = picsize[1] / scale self.sv2 = self.view['scrollview2'] self.sv2.content_size = (width, height) self.sv2v1 = self.sv2.subviews[0] #sv2v1 = view1 in scrollview2 self.sv2v1.bounds = (0, 0, width, height) self.sceneView = scene.SceneView(frame=self.sv2v1.bounds) self.sceneView.scene = MyPicture(self.view['scrollview1'].subviews[0].text, img, picsize) img = None self.sv2.add_subview(self.sceneView) else: self.view.close()
# iPad5,4 with a screen size of (1024 x 768) * 2 # # built on: # https://forum.omz-software.com/topic/2444/determining-pythonista-s-version/3 import os, platform, plistlib, scene, sys # noqa def pythonista_version(): # 2.0.1 (201000) plist = plistlib.readPlist( os.path.abspath(os.path.join(sys.executable, "..", "Info.plist"))) return "{CFBundleShortVersionString} ({CFBundleVersion})".format(**plist) ios_ver, _, machine_model = platform.mac_ver() bit = platform.architecture()[0].rstrip("bit") + "-bit" rez = "({:.0f} x {:.0f})".format(*scene.get_screen_size()) fmt = ("Pythonista version {} running Python {} on iOS {} on a {} {} with a " "screen size of {} * {:.0f}") print( fmt.format( pythonista_version(), platform.python_version(), ios_ver, bit, machine_model, rez, scene.get_screen_scale(), ))
# Python 3 # https://github.com/cclauss/Ten-lines-or-less/blob/master/pythonista_version.py # Output: Pythonista version 1.6 (160037) on iOS 9.2 on an iPad3,4. # Pythonista version 2.0.1 (201000) on iOS 9.2.1 on a 64-bit iPad5,4 with a screen size of (1024 x 768) * 2 # Pythonista version 3.0 (300007) running Python 3.5.1 on iOS 9.3.1 on a 64-bit iPad5,4 with a screen size of (1024 x 768) * 2 # Pythonista version 3.0 (300007) running Python 2.7.5 on iOS 9.3.1 on a 64-bit iPad5,4 with a screen size of (1024 x 768) * 2 # # built on https://forum.omz-software.com/topic/2444/determining-pythonista-s-version/3 import os, platform, plistlib, scene, sys def pythonista_version(): # 2.0.1 (201000) plist = plistlib.readPlist( os.path.abspath(os.path.join(sys.executable, '..', 'Info.plist'))) return '{CFBundleShortVersionString} ({CFBundleVersion})'.format(**plist) ios_ver, _, machine_model = platform.mac_ver() bit = platform.architecture()[0].rstrip('bit') + '-bit' rez = '({:.0f} x {:.0f})'.format(*scene.get_screen_size()) fmt = 'Pythonista version {} running Python {} on iOS {} on a {} {} with a screen size of {} * {:.0f}' print( fmt.format(pythonista_version(), platform.python_version(), ios_ver, bit, machine_model, rez, scene.get_screen_scale()))
from PIL import Image as PILImage from ui import Image as UIImage import io from ui import get_screen_size from scene import get_screen_scale appsize = (120, 120) screensize = tuple(int(i*get_screen_scale()) for i in get_screen_size()) if screensize[1] == 1136: screensize = screensize[0], 1096 def makegradient(c1, c2, size): img = PILImage.new('RGB', size, c1) d = tuple(c2[i]-c1[i] for i in range(3)) pixels = img.load() h = size[1] for i in range(h): c = tuple(c1[a] + d[a]*i/h for a in range(3)) for j in range(size[0]): pixels[j, i] = c return img def composite(top, bottom, offset): bottom = bottom.copy() top = top.convert('RGBA') r, g, b, a = top.split() top = PILImage.merge("RGB", (r, g, b)) mask = PILImage.merge("L", (a,)) bottom.paste(top, tuple(offset), mask) return bottom