class TestWindow(Window): """ Press Q or Escape to exit """ def __init__(self, *args, **kw): Window.__init__(self, *args, **kw) self.init_window() def init_window(self): self.gc = GraphicsContext(size=(self.width, self.height)) self.gc.gl_init() def on_key_press(self, symbol, modifiers): if symbol in (key.ESCAPE, key.Q): self.has_exit = True def draw(self): gc = self.gc with gc: gc.clear((0, 1, 0, 1)) gc.set_stroke_color((1,1,1,1)) gc.set_line_width(2) pts = array([[50, 50], [50,100], [100,100], [100,50]]) gc.begin_path() gc.lines(pts) gc.close_path() gc.draw_path(STROKE) gc.flush()
class TestWindow(Window): """ Press Q or Escape to exit """ def __init__(self, *args, **kw): Window.__init__(self, *args, **kw) self.init_window() def init_window(self): self.gc = GraphicsContext(size=(self.width, self.height)) self.gc.gl_init() def on_key_press(self, symbol, modifiers): if symbol in (key.ESCAPE, key.Q): self.has_exit = True def draw(self): gc = self.gc with gc: gc.clear((0, 1, 0, 1)) gc.set_stroke_color((1, 1, 1, 1)) gc.set_line_width(2) pts = array([[50, 50], [50, 100], [100, 100], [100, 50]]) gc.begin_path() gc.lines(pts) gc.close_path() gc.draw_path(STROKE) gc.flush()
def create_graphics_context(self, width=600, height=600, pixel_scale=2.0): from kiva.gl import GraphicsContext # XXX: Ignore scaling in the unit tests so this works on CI. # But really, we should just get rid of this rotted backend. self.window = pyglet.window.Window(width=width, height=height) gc = GraphicsContext((width, height), base_pixel_scale=1.0) gc.gl_init() return gc
def _create_gc(self, size, pix_format=None): """ Create a GraphicsContext instance. """ from pyglet.gl import Context gc = GraphicsContext((size[0] + 1, size[1] + 1)) self._pyglet_gl_context = Context() gc.gl_init() gc.translate_ctm(0.5, 0.5) return gc
def _create_gc(self, size, pix_format=None): """ Create a GraphicsContext instance. """ from pyglet.gl import Context gc = GraphicsContext((size[0] + 1, size[1] + 1)) self._pyglet_gl_context = Context() gc.gl_init() gc.translate_ctm(0.5, 0.5) return gc
def _create_gc(self, size, pix_format=None): """ Create a GraphicsContext instance. """ gc = GraphicsContext( (size[0] + 1, size[1] + 1), base_pixel_scale=self.base_pixel_scale, ) self._fake_pyglet_context = FakePygletContext() gc.gl_init() gc.translate_ctm(0.5, 0.5) return gc
def create_graphics_context(self, width, height): from kiva.gl import GraphicsContext self.window = pyglet.window.Window(width=width, height=height) gc = GraphicsContext((width, height)) gc.gl_init() return gc
def create_graphics_context(self, width, height): from kiva.gl import GraphicsContext self.window = pyglet.window.Window(width=width, height=height) gc = GraphicsContext((width, height)) gc.gl_init() return gc