Skip to content

Instantly share code, notes, and snippets.

@jsbain
Created August 21, 2018 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsbain/94b79fcd4241c518b77a5fcf60db2c89 to your computer and use it in GitHub Desktop.
Save jsbain/94b79fcd4241c518b77a5fcf60db2c89 to your computer and use it in GitHub Desktop.
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=[]
for v in range(0,random.randint(10,int(self.h/4))):
self.lines.append(ui.Path.rect(0, random.uniform(0,int(self.h)), self.w, random.uniform(1,10)))
ui.set_color(self.tint_color)
self.lines[v].stroke()
def update(self):
self.set_needs_display() #calls draw
topview=ui.load_view_str(pyui)
topview.bg_color=None
root=ui.View(bg_color='white')
bgv=bgLines(flex='wh')
bgv.alpha=.2
bgv.tint_color='red'
bgv.update_interval=.1
root.add_subview(bgv)
root.add_subview(topview)
root.present()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment