Пример #1
0
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()
Пример #2
0
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()
Пример #3
0
    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
Пример #4
0
    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
Пример #5
0
    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
Пример #6
0
 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
Пример #7
0
 def init_window(self):
     self.gc = GraphicsContext(size=(self.width, self.height))
     self.gc.gl_init()
Пример #8
0
def font_metrics_provider():
    from kiva.api import Font

    gc = GraphicsContext((1, 1))
    gc.set_font(Font())
    return gc
Пример #9
0
def font_metrics_provider():
    from kiva.fonttools import Font

    gc = GraphicsContext((1, 1))
    gc.set_font(Font())
    return gc
Пример #10
0
 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
Пример #11
0
 def init_window(self):
     self.gc = GraphicsContext(size=(self.width, self.height))
     self.gc.gl_init()
Пример #12
0
 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