def timer(self): phi = 2 * pi * get_elapsed_time() / 20.0 self.shader.modelview_matrix = ((cos(phi), 0, sin(phi), 0), (0, 1, 0, 0), (-sin(phi), 0, cos(phi), 0), (0, 0, 0, 1)) self.window.add_timer(10, self.timer) self.window.post_redisplay()
def timer(self): t = min(1.0, (get_elapsed_time() - self.transition_start) / self.transition_time) x = 0.5 - 0.5 * cos(pi * t) self.shader.minval = self.minstart * (1 - x) + self.minend * x self.shader.maxval = self.maxstart * (1 - x) + self.maxend * x if t < 1: self.window.add_timer(self.update_step, self.timer) self.window.post_redisplay()
def timer(self): t = min(1.0, (get_elapsed_time() - self.transition_start) / self.transition_time) x = 0.5 - 0.5 * cos(pi * t) self.shader.minval = self.minstart * (1 - x) + self.minend * x self.shader.maxval = self.maxstart * (1 - x) + self.maxend * x if t < 1: self.window.add_timer(self.update_step, self.timer) self.window.post_redisplay()
def timer(self): # We first get the elapsed time from GLUT using <code>get_elapsed_time()</code>: phi = 2 * pi * get_elapsed_time() / 20.0 # We then set the <code>modelview_matrix</code> uniform variable of the # shader simply by setting an attribute: self.shader.modelview_matrix = ((cos(phi), 0, sin(phi), 0), (0, 1, 0, 0), (-sin(phi), 0, cos(phi), 0), (0, 0, 0, 1)) # The following line schedules the next timer event to execute after ten milliseconds. self.window.add_timer(10, self.timer) # Finally, we tell GLUT to redraw the screen. self.window.post_redisplay()
def timer(self): phi = 2 * pi * get_elapsed_time() / 20.0 self.shader.modelview_matrix = ((cos(phi), 0, sin(phi), 0), (0, 1, 0, 0), (-sin(phi), 0, cos(phi), 0), (0, 0, 0, 1)) self.window.add_timer(10, self.timer) self.window.post_redisplay()
def start_transition(self, minval, maxval): self.minstart, self.maxstart = self.shader.minval, self.shader.maxval self.minend, self.maxend = minval, maxval self.transition_start = get_elapsed_time() self.timer()
def start_transition(self, minval, maxval): self.minstart, self.maxstart = self.shader.minval, self.shader.maxval self.minend, self.maxend = minval, maxval self.transition_start = get_elapsed_time() self.timer()