def __init__(self, font: pxng.Font, vertical_spacing=2): self._font = font self._vertical_spacing = vertical_spacing self._font_sprite = pxng.Sprite(self._font._font_data) self._display_list = pxng.DisplayList(8 * 16) self._initialized = False self._create_display_list()
def __init__(self, title, nes: Bus, asm_map: Dict[int, str]): super(HackerWindow, self).__init__(800, 500, title, scale=1, vsync=False) self.set_update_handler(self.draw_screen) self.nes: Bus = nes self.asm_map = asm_map self._emulation_run = False self._residual_time = 0.0 self._dirty = False self._selected_palette = 0x00 self._spr_ptrn_tbl_0 = pxng.Sprite(nes.ppu.spr_pattern_table[0]) self._spr_ptrn_tbl_1 = pxng.Sprite(nes.ppu.spr_pattern_table[1]) self._spr_screen = pxng.Sprite(nes.ppu.spr_screen)
mx, my = window.context['mouse'] pzmx, pzmy = world.screen_to_world(mx, my) world.apply_zoom() zmx, zmy = world.screen_to_world(mx, my) world.adjust_offset(pzmx - zmx, pzmy - zmy) fx1, fy1 = world.screen_to_world(0, 0) fx2, fy2 = world.screen_to_world(window.width, window.height) return Range2D(fx1, fy1, fx2, fy2) if __name__ == "__main__": w = 1280 h = 720 sprite = pxng.Sprite(np.zeros((h, w, 3), dtype=np.uint8)) window = pxng.Window(w, h, 'Fractal', scale=1) window.context = { 'sprite': sprite, 'count': 0, 'dirty': True, 'iterations': 128, 'rendering_time': 0, 'method': 'Shader', # Options: Rust, Python, Shader 'world': WorldSpace(0, 0, w, h, -2, -1, 1, 1), 'panning': False, 'mouse': (0, 0), 'mouse_delta': (0, 0), 'shaderfractal': ShaderFractal() }
def __init__(self, font: pxng.Font): self._font = font self._font_sprite = pxng.Sprite(self._font._font_data) self._renderer = FontRenderer()