def on_resize(self, width, height): """ Adjust projection to given size. """ # Compute new Projection xmin, xmax = 0, width ymin, ymax = 0, height if self.normalize: xmin, xmax = -1, +1 ymin, ymax = -1, +1 if self.xinvert: xmin, xmax = xmax, xmin if self.yinvert: ymin, ymax = ymax, ymin aspect = self.aspect if aspect is not None: if aspect > 1.0: xmin *= (aspect*width)//height xmax *= (aspect*width)//height else: ymin /= (aspect*width)//height ymax /= (aspect*width)//height znear, zfar = self.znear, self.zfar self["projection"] = glm.ortho(xmin, xmax, ymin, ymax, znear, zfar) # Propagate event to children Transform.on_resize(self, width, height)
def _build_projection(self): # We need to have caught at least one resize event if self._width is None: return # Compute new Projection xmin, xmax = 0, self._width ymin, ymax = 0, self._height if self._normalize: xmin, xmax = -1, +1 ymin, ymax = -1, +1 if self._xinvert: xmin, xmax = xmax, xmin if self._yinvert: ymin, ymax = ymax, ymin aspect = self._aspect if aspect is not None: if aspect > 1.0: xmin *= (aspect * self._width) / self._height xmax *= (aspect * self._width) / self._height else: ymin /= (aspect * self._width) / self._height ymax /= (aspect * self._width) / self._height znear, zfar = self._znear, self._zfar self["projection"] = glm.ortho(xmin, xmax, ymin, ymax, znear, zfar)
def create_transform(self, m, texture_size, target_size): texture_aspect = texture_size[0] / texture_size[1] target_aspect = target_size[0] / target_size[1] model = np.eye(4, dtype=np.float32) view = np.eye(4, dtype=np.float32) projection = glm.ortho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0) texture = np.eye(4, dtype=np.float32) if abs(texture_aspect - target_aspect) < 0.1: pass elif texture_aspect < target_aspect: # border left/right glm.scale(model, texture_aspect, 1.0, 1.0) #glm.scale(projection, 1.0 / target_aspect, 1.0, 1.0) glm.scale(texture, target_aspect, 1.0, 1.0) else: # border top/bottom glm.scale(model, 1.0, 1.0 / texture_aspect, 1.0) #glm.scale(projection, 1.0, target_aspect, 1.0) glm.scale(texture, 1.0, 1.0 / target_aspect, 1.0) model = np.dot(model, m) glm.scale(model, 1.0, -1.0, 1.0) return model, view, projection, texture
def _build_projection(self): # We need to have caught at least one resize event if self._width is None: return # Compute new Projection xmin, xmax = 0, self._width ymin, ymax = 0, self._height if self._normalize: xmin, xmax = -1, +1 ymin, ymax = -1, +1 if self._xinvert: xmin, xmax = xmax, xmin if self._yinvert: ymin, ymax = ymax, ymin aspect = self._aspect if aspect is not None: if aspect > 1.0: xmin *= (aspect*self._width)/self._height xmax *= (aspect*self._width)/self._height else: ymin /= (aspect*self._width)/self._height ymax /= (aspect*self._width)/self._height znear, zfar = self._znear, self._zfar self["projection"] = glm.ortho(xmin, xmax, ymin, ymax, znear, zfar)
def on_resize(self, width, height): """ Adjust projection to given size. """ # Compute new Projection xmin, xmax = 0, width ymin, ymax = 0, height if self.normalize: xmin, xmax = -1, +1 ymin, ymax = -1, +1 if self.xinvert: xmin, xmax = xmax, xmin if self.yinvert: ymin, ymax = ymax, ymin aspect = self.aspect if aspect is not None: if aspect > 1.0: xmin *= (aspect * width) / height xmax *= (aspect * width) / height else: ymin /= (aspect * width) / height ymax /= (aspect * width) / height znear, zfar = self.znear, self.zfar self["projection"] = glm.ortho(xmin, xmax, ymin, ymax, znear, zfar) # Propagate event to children Transform.on_resize(self, width, height)
def on_resize(width, height): gl.glViewport(0, 0, width, height) C['projection'] = glm.ortho(0, width, 0, height, -1, +1) i = 0 for x in [0,width//2, width]: for y in [0,height//2, height]: C[i]['translate'] = x,y i += 1
def on_resize(width, height): # half_w, half_h = width * 0.5, height * 0.5 hw = width / float(height) hh = 1.0 if hw > 1.0: hh = 1.0 / hw hw = 1.0 print('frustum boundary, horizontal: {}, vertical boundary: {}'.format( hw, hh)) program['u_projection'] = glm.ortho(-hw, hw, -hh, hh, -100, 100)
def _create_transformation(self, texture_size, target_size): texture_aspect = texture_size[0] / texture_size[1] target_aspect = target_size[0] / target_size[1] model = np.eye(4, dtype=np.float32) view = np.eye(4, dtype=np.float32) projection = glm.ortho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0) if texture_aspect < target_aspect: # border left/right glm.scale(model, texture_aspect, 1.0, 1.0) glm.scale(projection, 1.0 / target_aspect, 1.0, 1.0) else: # border top/bottom glm.scale(model, 1.0, 1.0 / texture_aspect, 1.0) glm.scale(projection, 1.0, target_aspect, 1.0) return model, view, projection
def on_resize(width, height): program['projection'] = glm.ortho(0, width, 0, height, -1, +1) program['viewport'] = 0,0,width,height compute_grid() program['u_grid'][...] = Z
def on_resize(width, height): cones['projection'] = glm.ortho(0, width, 0, height, -5, +500) borders.viewport = 0, 0, width, height
def on_resize(width, height): program['projection'] = glm.ortho(0, width, 0, height, -1, +1) program['viewport'] = 0, 0, width, height
def on_resize(width, height): C['projection'] = glm.ortho(0, width, 0, height, -1, +1)
def on_resize(width, height): program["projection"] = glm.ortho(0, width, 0, height, -1, +1) program["viewport"] = 0, 0, width, height
def on_resize(self, width, height): self["projection"] = glm.ortho(0, width, 0, height, +1,-1)
def on_resize(self, width, height): """ Update console projection """ self._program["projection"] = glm.ortho(0, width, height, 0, -1, +1)
def on_resize(self, width, height): self._program["projection"] = glm.ortho(0, width, height, 0, -1, +1)
def on_resize(width, height): program['u_projection'] = glm.ortho(0, width, 0, height, -1, +1)
def on_resize(width, height): gl.glViewport(0, 0, width, height) C['projection'] = glm.ortho(0, width, 0, height, -1, +1) C['translate'] = width//2,height//2
def on_resize(width, height): program['projection'] = glm.ortho(0, width, 0, height, -1, +1) program['viewport'] = 0,0,width,height
def on_draw(dt): nonlocal bpm_window_average, p window.clear() audio.process() if audio.beat_on.value: bpm = float(bpm_from_last_beat) print(bpm) if is_bpm_sensible(bpm): current_bpm.value = bpm_window_average(bpm) print("--- bpm", bpm, "---") else: print("hmm?", bpm) last_beat.value = float(time) is_beat_running = bpm_fits_lower_threshold(bpm_from_last_beat) if not is_beat_running and not p: bpm_window_average = sliding_window_average(8) print("-- empty --") p = True if is_beat_running: p = False w, h = window.get_size() pipeline.render_screen(None, (w, h)) if render_hud: #print(audio._current_beat_amplitude, audio.vu.value, audio.vu_norm.value) #print(audio.vu._evaluated, audio.vu._value) color = (0.0, 1.0, 0.0, 1.0) bg_color = (0.0, 0.0, 0.0, 0.8) box_height = 200 bounds = (10, h - box_height - 10, w - 10, h - 10) threshold_color = (1.0, 0.0, 0.0, 1.0) threshold = audio.beat_threshold threshold_y = float( var.Const(threshold).map_range(0.0, 1.0, bounds[3], bounds[1])) ortho_px = glm.ortho(0, w, 0, h, -1.0, 1.0) glm.scale(ortho_px, 1.0, -1.0, 1.0) plot_values(audio.beat_values, ortho_px, bounds, color, bg_color, [0.0, 1.0]) primitive.draw_line((bounds[0], threshold_y), (bounds[2], threshold_y), threshold_color, ortho_px) #fft = audio._current_fft #freqs = fftpack.fftfreq(len(fft), d=1.0 / 5000.0) #fft = fft[0:len(fft) // 2] * 0.05 #if len(fft) > 1: # plot_bar_values(fft, ortho_px, (10, 10, w - 10, 210), color, bg_color, [0.0, 1.0]) #print(freqs) imgui_renderer.process_inputs() imgui.new_frame() imgui.show_test_window() imgui.set_next_window_position(10, 10, condition=imgui.ALWAYS, pivot_x=0, pivot_y=0) imgui.set_next_window_size(0.0, 0.0) flags = imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_NO_RESIZE + imgui.WINDOW_NO_MOVE + imgui.WINDOW_NO_COLLAPSE imgui.begin("Stats", None, flags) imgui.text("FPS: %.2f" % app.clock.get_fps()) imgui.text("Current BPM: %.2f" % current_bpm.value) imgui.text("Beat running: %s" % { True: "Yes", False: "Nope" }[is_beat_running]) imgui.end() imgui.render() imgui_renderer.render(imgui.get_draw_data()) #print("Resetting:", repr(Event), audio.vu in Event._instances) Event.reset_instances() GenerativeStage.reset_instances() var.ReloadVar.reload_vars()
def on_resize(width, height): cones['projection'] = glm.ortho(0, width, 0, height, -5, +500)
def on_resize(width, height): program['projection'] = glm.ortho(0, width, 0, height, -1, +1) program['viewport'] = 0, 0, width, height compute_grid() program['u_grid'][...] = Z
def on_resize(width, height): cones['projection'] = glm.ortho(0, width, 0, height, -5, +500) borders.viewport = 0,0,width,height
def on_resize(width, height): gl.glViewport(0, 0, width, height) projection = glm.ortho(0, width, 0, height, -1, +1) program['u_projection'] = projection
def on_resize(width, height): program["projection"] = glm.ortho(0, width, 0, height, -1, +1) program["viewport"] = 0, 0, width, height compute_grid() program["u_grid"][...] = Z
def on_resize(width, height): global mvp mvp = glm.ortho(0, width, 0, height, -1.0, 1.0) glm.scale(mvp, 1.0, -1.0, 1.0)