def update_glsl(self, *largs): va = (self.width/float(self.height)) /2.0 self.render_ctx['time'] = t = Clock.get_boottime() self.render_ctx['projection_mat'] = Matrix().view_clip(-va,va,-.5,.5, .95,100, 1) self.render_ctx['light_pos'] = [0, 0.0, 0] for k in self.mesh_colors.keys(): self.mesh_colors[k].rgba = (1,1,1,1) if self.mesh_colors.get(self.selected_county): self.mesh_colors[self.selected_county].rgba = (1,0,0,1) self.cb.ask_update() self.render_ctx.ask_update() self.fbo.ask_update() #self.rot.angle = sin(t*0.12)*cos(t*0.22)*20 #self.roty.angle = cos(sin(t*0.23))*15 self._p_render_ctx['time'] = t = Clock.get_boottime() self._p_render_ctx['resolution'] = map(float, self.size) self._p_render_ctx['projection_mat'] = Matrix().view_clip(-va,va,-.5,.5, .95,100, 1) self._p_render_ctx['light_pos'] = [0, 0.0, 0] self._p_cb.ask_update() self._p_render_ctx.ask_update() self._p_fbo.ask_update() #self._p_rot.angle = sin(t*0.12)*cos(t*0.22)*20 #self._p_roty.angle = cos(sin(t*0.23))*15 self.canvas.ask_update()
def update_glsl(self, *largs): for i, (name, fbo) in enumerate(self.fbos.items()): glActiveTexture(GL_TEXTURE0 + 1) fbo.texture.bind() self.canvas[str(name)] = 1 for sfbo in self.fbos.values(): sfbo.canvas[str(name)] = 1 fbo.canvas['iGlobalTime'] = Clock.get_boottime() fbo.canvas['iResolution'] = list(map(float, self.size)) + [0.0] # This is needed for the default vertex shader. fbo.canvas['projection_mat'] = Window.render_context['projection_mat'] fbo.bind() fbo.canvas.draw() fbo.release() glActiveTexture(GL_TEXTURE0 + 1) fbo.texture.bind() self.canvas['iGlobalTime'] = Clock.get_boottime() self.canvas['iResolution'] = list(map(float, self.size)) + [0.0] # This is needed for the default vertex shader. self.canvas['projection_mat'] = Window.render_context['projection_mat'] mtime = os.path.getmtime(self.shaderfn) umtime = os.path.getmtime('utility.glf') if mtime != self.time_last or umtime != self.utime_last: self.on_fs(self, self.shaderfn) self.time_last = mtime
def on_touch_down(self, touch): # Doesn't do anything if touched within the tenth first seconds. if abs(Clock.get_boottime() - self.last_runtime) > TOUCH_DELAY: if not self.credits_touchedMessageSent: print "Credits touched at, ", Clock.get_boottime() self.controller.sendMessage("credits_touched") # go back to mode2, Learning self.credits_touchedMessageSent = True
def first_apex(self, dt): a = Apex() a.x = randint(self.width/4, 3*self.width/4) a.y = randint(self.height+25,self.height+125) a.clock = Clock.get_boottime() a.huntclock = Clock.get_boottime() + 10 a.dx = uniform(-1.0, 1.0) a.dy = uniform(-1.5, -.5) self.add_widget(a) self.cl.append(a)
def first_tooth(self, dt): t = Tooth() t.x = randint(self.width/4, 3*self.width/4) t.y = randint(self.height+25,self.height+125) t.clock = Clock.get_boottime() t.huntclock = Clock.get_boottime() + 3 t.dx = uniform(-2.0, 2.0) t.dy = uniform(-2.0, -1.0) t.mass = 35.0 self.add_widget(t) self.cl.append(t)
def update(self, dt): if not self.running: return if self.last_tick is None: self.last_tick = Clock.get_boottime() current_tick = Clock.get_boottime() - FREQUENCY while current_tick > self.last_tick: self.last_tick += FREQUENCY self.tick()
def scroll(self, dt): t = Clock.get_boottime() modifier = 0.3 for rectangle in self.rectangles: rectangle.tex_coords = -(t * modifier), 0, -(t * modifier + 1), 0, -(t * modifier + 1), -1, -(t * modifier), -1 modifier /= 2
def update_glsl(self, *largs): va = (self.width/float(self.height)) /2.0 self.render_ctx['time'] = t = Clock.get_boottime() self.render_ctx['resolution'] = map(float, self.size) self.render_ctx['projection_mat'] = Matrix().view_clip(-va,va,-.5,.5, .95,100, 1) self.render_ctx['light_pos'] = [0, 0.0, 0] for k in self.mesh_transforms.keys(): parts = k.split("_") county = parts[1] if len(parts) > 3: county += "_" +parts[2] pop = self.population_data[county][self.slider_val] #v = t+t*(self.start_t[k]+1) #v = (sin(v)*cos(v)+2) v = pop / 400000.0 lv = lscale(pop,3900.,360000.) self.mesh_transforms[k].matrix = Matrix().scale(1, 1, lv*4.0+0.5) self.mesh_colors[k].hsv = ((1.0-lv)*0.3 ,1.0,1.0) self.cb.ask_update() self.render_ctx.ask_update() self.fbo.ask_update() self.canvas.ask_update() self.rot.angle = sin(t*0.12)*cos(t*0.22)*20 self.roty.angle = cos(sin(t*0.23))*15
def calc_velocity(self): self.touch_time = Clock.get_boottime() - self.touch_time self.touch_time = self.touch_time * 35 if self.touch_time < 2: #creates a minimum velocity self.touch_time = 15 if self.touch_time > 25: #creates a maximum velocity self.touch_time = 25
def parse_logs( self, logs ) : self.__last_log_parse= Clock.get_boottime() name2text_timelines= defaultdict( list ) # name -> [ ( text, timeline ), ] self.__parse_logs( name2text_timelines, logs ) for name, text_timelines in name2text_timelines.iteritems() : ui_owner= self.ui_owner_by_name( name ) if ui_owner is not None : self.__float_text_atlas.clear() if ui_owner is self : self.__float_text_atlas.width= 0 self.__float_text_atlas.height= 99999 else : self.__float_text_atlas.width= metrics.dp( 150 ) self.__float_text_atlas.height= 99999 if ui_owner is self : pos= ( ui_owner.center[0], ui_owner.center[1] ) halign= u'center' elif ui_owner.character.camp == self.self_camp : pos= ( ui_owner.right, ui_owner.y ) halign= u'left' elif ui_owner.character.camp != self.self_camp : pos= ( ui_owner.x, ui_owner.y ) halign= u'right' else : continue for text, full_text, timelines in reversed( text_timelines ) : float_text_atlas( self.__float_text_atlas, ui_owner.canvas.after, text, pos, timelines, halign ) self.log_text += full_text self.log_text += '\n' self.__float_text_atlas.clear()
def update_glsl(self, *largs): self.canvas['time'] = Clock.get_boottime() self.canvas['resolution'] = list(map(float, self.size)) # This is needed for the default vertex shader. win_rc = Window.render_context self.canvas['projection_mat'] = win_rc['projection_mat'] self.canvas['modelview_mat'] = win_rc['modelview_mat'] self.canvas['frag_modelview_mat'] = win_rc['frag_modelview_mat']
def getAt(self): retourTexture = None bootTime = Clock.get_boottime() if bootTime - self.last >= self.delay: self.last = bootTime retourTexture = self.next() return retourTexture
def on_btn_start(self, str_rate): try: rate = float(str_rate) except ValueError: return self.rate = rate self.running = True self.time_at_last_start = Clock.get_boottime()
def update_glsl(self, *largs): self.render_ctx['time'] = t = Clock.get_boottime() self.render_ctx['resolution'] = map(float, self.size) self.render_ctx['projection_mat'] = Matrix().view_clip(-va,va,-.5,.5, .95,100, 1) self.render_ctx['light_pos'] = [0, 0.0, 0] self.cb.ask_update() self.render_ctx.ask_update() self.fbo.ask_update() self.canvas.ask_update()
def first_square(self, dt): s = Square() s.x = randint(0, self.width-s.mass) s.y = randint(0, self.height-s.mass) s.clock = Clock.get_boottime() s.dx = uniform(-1.5,1.5) s.dy = uniform(-1.5,1.5) self.add_widget(s) self.cl.append(s)
def open_menu(self, dt): m = Menu() m.x = randint(0, self.width-m.mass) m.y = randint(0, self.height-m.mass) m.clock = Clock.get_boottime() m.dx = uniform(-0.3,0.3) m.dy = uniform(-0.3,0.3) self.add_widget(m) self.cl.append(m)
def first_big(self, dt): b = Big() b.x = randint(self.width/4, 3*self.width/4) b.y = randint(self.height+40,self.height+140) b.clock = Clock.get_boottime() b.dx = uniform(-1.0, 1.0) b.dy = uniform(-.75, -.5) self.add_widget(b) self.cl.append(b)
def new_tooth(self, x, y): t = Tooth() t.center_x = x t.center_y = y t.clock = Clock.get_boottime() t.dx = uniform(-2.0, 2.0) t.dy = uniform(-2.0, 2.0) self.add_widget(t) self.cl.append(t)
def update_glsl(self, *largs): self.canvas['time'] = t = Clock.get_boottime() self.canvas['resolution'] = map(float, self.size) self.canvas['projection_mat'] = Matrix().view_clip(-.5,.5,-.5,.5, 1,100, 1) self.canvas['light_pos'] = [0, 0.0, 0] for k in self.mesh_transforms.keys(): #v = t+t*(self.start_t[k]+1) #v = (sin(v)*cos(v)+2) v = self.start_t[k] + 1.0 self.mesh_transforms[k].matrix = Matrix().scale(1, 1, v)
def new_square(self, x, y): s = Square() s.center_x = x s.center_y = y s.clock = Clock.get_boottime() s.dx = uniform(-1.5,1.5) s.dy = uniform(-1.5,1.5) self.add_widget(s) self.cl.append(s)
def first_drifter(self, dt): d = Drifter() d.x = randint(self.width/4, 3*self.width/4) d.y = randint(self.height,self.height+40) d.clock = Clock.get_boottime() d.dx = uniform(-0.1, 0.1) d.dy = uniform(-.75, -.5) self.add_widget(d) self.cl.append(d)
def open_end(self, dt): e = End() e.x = randint(0, self.width-e.mass) e.y = randint(0, self.height-e.mass) e.clock = Clock.get_boottime() e.dx = uniform(-0.3,0.3) e.dy = uniform(-0.3,0.3) e.a_score = self.a_score e.p_score = self.p_score self.add_widget(e) self.cl.append(e)
def update_glsl(self, *largs): self.canvas['iGlobalTime'] = Clock.get_boottime() self.canvas['iResolution'] = list(map(float, self.size)) + [0.0] # This is needed for the default vertex shader. self.canvas['projection_mat'] = Window.render_context['projection_mat'] mtime = os.path.getmtime(self.shaderfn) if mtime != self.time_last: #print 'foo!' self.on_fs(self, self.shaderfn) self.time_last = mtime
def _update_glsl(self, *largs): '''(internal) Passes new time and resolution uniform variables to the shader. ''' time = Clock.get_boottime() resolution = [float(size) for size in self.size] self.canvas['time'] = time self.canvas['resolution'] = resolution for fbo in self.fbo_list: fbo['time'] = time fbo['resolution'] = resolution
def update_glsl(self, *largs): time = Clock.get_boottime() resolution = [float(size) for size in C_SIZE] self.canvas['time'] = time self.canvas['resolution'] = resolution self.canvas['texture4'] = 4 self.canvas['texture5'] = 5 for fbo in self.fbo_list: fbo['time'] = time fbo['resolution'] = resolution fbo['texture4'] = 4 fbo['texture5'] = 5
def update(self, dt): if (self.ball.y <0) or (self.ball.top > self.height): self.ball.velocity_y *= -0.95 elif (self.ball.x < 0) or (self.ball.right > self.width): self.ball.velocity_x *= -1 else: self.ball.velocity_y += -grav*(Clock.get_boottime()**2) self.ball.move()
def update_glsl(self, *largs): va = (self.width/float(self.height)) /2.0 self.render_ctx['time'] = t = Clock.get_boottime() self.render_ctx['resolution'] = map(float, self.size) self.render_ctx['projection_mat'] = Matrix().view_clip(-va,va,-.5,.5, .95,100, 1) self.render_ctx['light_pos'] = [0, 0.0, 0] self.rot.angle = sin(t*0.5)* 15.0 self.rot2.angle = sin(t*0.3)* 9.0 self.mi.matrix = Matrix().scale(5,5,1).scale(6,6,6) self.cb.ask_update() self.render_ctx.ask_update() self.fbo.ask_update() self.canvas.ask_update()
def txupdate(self, *l): t = Clock.get_boottime() v = 0.05 ratio = round(self.width / self.height, 1) if self.stage % 2 == 1: self.rect_1.tex_coords = - \ (t * v), 0, -(t * v + ratio), 0, - \ (t * v + ratio), -1, -(t * v), -1 else: self.rect_1.tex_coords = - \ (t * v), 0, -(t * v - ratio), 0, - \ (t * v - ratio), -1, -(t * v), -1
def update_shader(self, *args): s = self.canvas #s['projection_mat'] = Window.render_context['projection_mat'] s['projection_mat'] = Window.render_context['projection_mat'] s['time'] = Clock.get_boottime() s['resolution'] = list(map(float, self.size)) #if form.gl_widget.pos is not None: #form.image_rect.pos=form.gl_widget.pos #if form.gl_widget.size is not None: #form.image_rect.size=form.gl_widget.size form.vs_label.height=form.vs_label.texture_size[1] + 10 form.fs_label.height=form.fs_label.texture_size[1] + 10 s.ask_update()
def on_touch_up(self, touch): for child in self.children: if child.collide_point(*touch.pos): if child.type == 'Menu' or child.type == 'End': self.remove_widget(child) self.cl.remove(child) Clock.schedule_once(root.first_square) Clock.schedule_interval(root.balance, 1.0) self.canseed = True self.a_score = 0 self.p_score = 0 self.plantlimit = 16 if self.start_sound: #self.start_sound.play() pass if self.game_music: #self.game_music.play() #self.game_music.loop = True pass elif child.type == 'Tooth': child.freeze() elif child.type == 'Big': t = Clock.get_boottime() child.touchflee(touch, t) elif child.type == 'Drifter': child.reverse() return if self.canseed: p = Plant(pos=(touch.x-10, touch.y-10)) p.clock = Clock.get_boottime() self.add_widget(p) self.cl.append(p)
def update(self, dt): if (self.running): self.total_time = self.saved_time + Clock.get_boottime( ) - self.time_at_last_start self.total = self.total_time * (self.rate / 3600.0) self.time_str = str(timedelta(seconds=int(self.total_time)))
def update_anim(self, dt): """Update the animation for this logo.""" t = Clock.get_boottime() * .1 self.fg.tex_coords = (-t, t + 1, -t + 1, t + 1, -t + 1, t, -t, t)
def on_btn_reset(self): self.time_at_last_start = Clock.get_boottime() self.saved_time = 0.0 self.time_str = "0:00:00" self.total = 0
def print_something(self, *args): print('App print tick', Clock.get_boottime())
def update_glsl(self, *largs): self.canvas['time'] = Clock.get_boottime() self.canvas['resolution'] = [float(v) for v in self.size]
def increase_time(self, dt): self.time = Clock.get_boottime()
def move(self, *l): global start_n t = Clock.get_boottime() # Direction of Movement # Upper Right Quadrant if Window.mouse_pos[0] >= ( Window.width / 2) and Window.mouse_pos[1] >= (Window.height / 2): a = -(Window.mouse_pos[1] - Window.height / 2) b = -(Window.mouse_pos[0] - Window.width / 2) # Upper Left Quadrant elif Window.mouse_pos[0] <= ( Window.width / 2) and Window.mouse_pos[1] >= (Window.height / 2): a = -(Window.mouse_pos[1] - Window.height / 2) b = Window.width / 2 - Window.mouse_pos[0] # Lower Left Quadrant elif Window.mouse_pos[0] <= ( Window.width / 2) and Window.mouse_pos[1] <= (Window.height / 2): a = Window.height / 2 - Window.mouse_pos[1] b = Window.width / 2 - Window.mouse_pos[0] # Lower Right Quadrant elif Window.mouse_pos[0] >= ( Window.width / 2) and Window.mouse_pos[1] <= (Window.height / 2): a = Window.height / 2 - Window.mouse_pos[1] b = -(Window.mouse_pos[0] - Window.width / 2) bottom = abs(a) + abs(b) x_rate = b / bottom y_rate = a / bottom # Move the ball's tail self.ball.flame_1.pos = (4 * x_rate + Window.width / 2, 4 * y_rate + Window.height / 2) self.ball.flame_2.pos = (7 * x_rate + Window.width / 2, 7 * y_rate + Window.height / 2) self.ball.flame_3.pos = (10 * x_rate + Window.width / 2, 10 * y_rate + Window.height / 2) self.ball.flame_4.pos = (13 * x_rate + Window.width / 2, 13 * y_rate + Window.height / 2) self.ball.flame_5.pos = (16 * x_rate + Window.width / 2, 16 * y_rate + Window.height / 2) self.ball.flame_6.pos = (19 * x_rate + Window.width / 2, 19 * y_rate + Window.height / 2) # Move the planet self.planet.rect_1.pos = (dif_rate * x_rate * t + self.planet.rect_1.pos[0], dif_rate * y_rate * t + self.planet.rect_1.pos[1]) # When it goes out of the screen if self.planet.rect_1.pos[ 0] > Window.width + self.planet.rect_1.size[0]: self.planet.rect_1.pos = (0 - self.planet.rect_1.size[0], random.randrange(0, Window.height)) elif self.planet.rect_1.pos[0] < 0 - self.planet.rect_1.size[0]: self.planet.rect_1.pos = (Window.width + self.planet.rect_1.size[0], random.randrange(0, Window.height)) elif self.planet.rect_1.pos[ 1] > Window.height + self.planet.rect_1.size[1]: self.planet.rect_1.pos = (random.randrange(0, Window.width), 0 - self.planet.rect_1.size[1]) elif self.planet.rect_1.pos[1] < 0 - self.planet.rect_1.size[1]: self.planet.rect_1.pos = (random.randrange( 0, Window.width), Window.height + self.planet.rect_1.size[1]) # Move the stars for item in self.star.starlist: item.pos = (dif_rate * x_rate * t + item.pos[0], dif_rate * y_rate * t + item.pos[1]) # When it goes out of the screen if item.pos[0] >= Window.width + item.size[0]: item.pos = (0 - item.size[0], random.randrange(0, Window.height)) elif item.pos[0] <= 0 - item.size[0]: item.pos = (Window.width + item.size[0], random.randrange(0, Window.height)) elif item.pos[1] >= Window.height + item.size[1]: item.pos = (random.randrange(0, Window.width), 0 - item.size[1]) elif item.pos[1] <= 0 - item.size[1]: item.pos = (random.randrange(0, Window.width), Window.height + item.size[1]) # Move the meteorites # Move the meteorites along with the background for item in self.meteorites.meteolist: item.pos = (dif_rate * x_rate * t + item.pos[0], dif_rate * y_rate * t + item.pos[1]) # When it goes out of the screen if start_n == 2: start_n = -1 start_n += 1 if (item.pos[0] > Window.width + item.size[0] or item.pos[0] < 0 - item.size[0] or item.pos[1] > Window.height + item.size[1] or item.pos[1] < 0 - item.size[1]): random_N = random.randint(1, 4) if random_N == 1: # from BOTTOM item.pos = (random.randrange(1, Window.width - 1), 0 - item.size[1]) self.meteorites.meteolist_ini[start_n].pos = item.pos elif random_N == 2: # from LEFT item.pos = (0 - item.size[0], random.randrange(1, Window.height - 1)) self.meteorites.meteolist_ini[start_n].pos = item.pos elif random_N == 3: # from TOP item.pos = (random.randrange(1, Window.width - 1), Window.height + item.pos[1]) self.meteorites.meteolist_ini[start_n].pos = item.pos else: # from RIGHT item.pos = (Window.width + item.size[0], random.randrange(1, Window.height - 1)) self.meteorites.meteolist_ini[start_n].pos = item.pos # Move the metorites in straight paths for item in self.meteorites.meteolist_ini: if start_n == 2: start_n = -1 start_n += 1 # Upper Right Quadrant if item.pos[0] >= (Window.width / 2) and item.pos[1] == Window.height + 20: x = -(item.pos[0] - (Window.width / 2)) y = -(Window.height / 2 + 20) elif item.pos[0] == Window.width + 20 and item.pos[1] >= ( Window.height / 2): x = -(Window.width / 2 + 20) y = -(item.pos[1] - (Window.height / 2)) # Upper Left Quadrant elif item.pos[0] <= (Window.width / 2) and item.pos[1] == Window.height + 20: x = (Window.width / 2) - item.pos[0] y = -(Window.height / 2 + 20) elif item.pos[0] == (-20) and item.pos[1] >= (Window.height / 2): x = (Window.width / 2 + 20) y = -(item.pos[1] - (Window.height / 2)) # Lower Left Quadrant elif item.pos[0] == (-20) and item.pos[1] <= (Window.height / 2): x = (Window.width / 2 + 20) y = (Window.height / 2) - item.pos[1] elif item.pos[0] <= (Window.width / 2) and item.pos[1] == (-20): x = (Window.width / 2) - item.pos[0] y = (Window.height / 2 + 20) # Lower Right Quadrant elif item.pos[0] >= (Window.width / 2) and item.pos[1] == (-20): x = -item.pos[0] - (Window.width / 2) y = (Window.height / 2 + 20) else: x = -(Window.width / 2 + 20) y = (Window.height / 2) - item.pos[1] bottom_new = abs(x) + abs(y) x_rate_new = x / bottom_new y_rate_new = y / bottom_new self.meteorites.meteolist[start_n].pos = ( 6 * dif_rate * x_rate_new * t + self.meteorites.meteolist[start_n].pos[0], 6 * dif_rate * y_rate_new * t + self.meteorites.meteolist[start_n].pos[1])
def update(self, dt): self.boottime = Clock.get_boottime() self.fps = Clock.get_fps() self.rfps = Clock.get_rfps() self.frames_drawn = Clock.frames_displayed self.frames_total = Clock.frames
def change_scatter_alpha(self, dt): from math import cos self.root.alpha = abs(cos(Clock.get_boottime()))
def update_glsl(self, *largs): self.canvas['time'] = Clock.get_boottime()
def update(self, dt): t1 = time.clock() current_elapsed = Clock.get_boottime() current_elapsed_int = round(current_elapsed, 0) #print('CEI: {}'.format(current_elapsed_int)) # This update function is the main update function for the game # All of the game logic has its origin here # events are setup here as well # update game objects # update ship #while self.ship.y < Window.height / 8: # print(self.ship.y) # self.ship.y += 0.002 if self.title: return self.ship.update() if self.opening_sequence: if self.ship.y < Window.height / 8: self.ship.y += 2 self.flame.y += 2.05 return else: #self.rocket_takeoff_sound.stop() self.opening_sequence = False #self.flame.rocket_takeoff_sound.stop() #self.remove_widget(self.flame) #self.background.update() #self.update_score() # update asteroids # randomly add an asteroid tmpCount = random.randint(1, self.asteroid_probability_max) if tmpCount > self.minProb and len(self.asteroidList) <= self.max_number_of_asteroids: self.update_score() self.add_asteroid() self.max_asteroid_velocity += 1 self.min_asteroid_velocity += 1 if self.minProb < 1300: self.minProb = 1300 self.minProb = self.minProb - 1 #if current_elapsed_int % 2 == 0: #print(current_elapsed_int) asteroid_tmp = self.asteroidList[:] asteroids_removed = 0 for i, asteroid in enumerate(asteroid_tmp): if asteroid.pos[1] + asteroid.size[1] < 0: actual_i = i - asteroids_removed target = self.asteroidList[actual_i] self.remove_widget(target) self.asteroidList.pop(actual_i) asteroids_removed += 1 self.number_of_asteroids_removed += asteroids_removed for k in self.asteroidList: # check for collision with ship if k.collide_widget(self.ship): #self.ship.explode() #self.add_widget(self.explosion) #self.explosion.explode(self.ship.pos, self.ship.size) self.ship.explode() self.remove_widget(self.flame) #self.remove_widget(self.ship) 'death' # game over routine self.gameOver() Clock.unschedule(self.update) # add reset button k.update() t2 = time.clock() self.delt = t2 - t1 self.debug_label.text = '{:.5}'.format(self.delt)
def update_shader_time(self, dt): self.root.shader_widget.canvas['time'] = Clock.get_boottime()
def pulse_widget_alpha(self, dt): from math import cos self.alpha = abs(cos(Clock.get_boottime()))
def show_time(self, *l): with self.canvas: self.button = Button(pos=(Window.width - 160, Window.height - 90), size=(100, 60)) self.button.background_color = (1, 0.3, 0.3, 0.7) self.button.text += str(round(Clock.get_boottime(), 3))
def update_glsl(self, *largs): self.canvas['time'] = Clock.get_boottime() self.canvas['resolution'] = list(map(float, self.size)) # This is needed for the default vertex shader. self.canvas['projection_mat'] = Window.render_context['projection_mat']
def update(self): t = Clock.get_boottime() u = 0 v = t * 0.02 w = 1 h = 1
def update_shader(self, *args): s = self.canvas s['projection_mat'] = Window.render_context['projection_mat'] s['time'] = Clock.get_boottime() s['resolution'] = list(map(float, self.size)) s.ask_update()
def update_glsl(self, *largs): self.canvas['time'] = Clock.get_boottime() self.canvas['resolution'] = map(float, self.size)
def on_parent(self, instance, parent): if parent is None: Clock.unschedule(self.increase_time) else: Clock.schedule_interval(self.increase_time, 1 / 30.) self.time = Clock.get_boottime()
def wakeup(*_): self.backlight_idle = Clock.get_boottime() if not self.backlight_on: print('turn back on!') self.pitft.enable_backlight() self.backlight_on = True