コード例 #1
0
ファイル: paint.py プロジェクト: ev3dev/grx
 def handle_pen_down(self, x, y):
     if y <= self.color_picker_y:
         idx = x * len(self.colors) // Grx.get_width()
         self.fg_color = self.colors[self.color_lookup[idx]]
     else:
         self.pen_x, self.pen_y = x, y
         self.pen_down = True
         Grx.draw_pixel(self.pen_x, self.pen_y, self.fg_color)
コード例 #2
0
ファイル: paint.py プロジェクト: tanglemore/grx
 def handle_pen_down(self, x, y):
     if y <= self.color_picker_y:
         idx = x * len(self.colors) // Grx.get_width()
         self.fg_color = self.colors[self.color_lookup[idx]]
     else:
         self.pen_x, self.pen_y = x, y
         self.pen_down = True
         Grx.draw_pixel(self.pen_x, self.pen_y, self.fg_color)
コード例 #3
0
ファイル: pixels.py プロジェクト: tanglemore/grx
def activate(app):
    w = Grx.get_width()
    colors = Grx.color_get_ega_colors()
    smile = demo.get_smiley_pixmap(32, 32)

    # draw the full width of the screen
    for x in range(0, w, 3):
        # draw a band with colored pixels
        for y in range(10, 30, 2):
            Grx.draw_pixel(x + y % 3, y, colors[(y - 1) % 16])

        # draw a band with pixels from a pixmap
        for y in range(40, 60, 2):
            Grx.draw_filled_pixel_with_pixmap(x + y % 3, y, smile)

        # draw a band with pixels from a pixmap, but offset this time
        for y in range(70, 90, 2):
            Grx.draw_pixel_with_offset_pixmap(16, 0, x + y % 3, y, smile)
コード例 #4
0
ファイル: input.py プロジェクト: tanglemore/grx
    def do_event(self, event):
        if Grx.Application.do_event(self, event):
            return True

        t = event.type
        if t in (Grx.EventType.KEY_DOWN, Grx.EventType.KEY_UP):
            key_event = event.key
            print("key keysym", key_event.keysym)
            print("key unichar", key_event.unichar)
            print("key code", key_event.code)
            print("modifiers", key_event.modifiers)
            if key_event.keysym in (Grx.Key.LCASE_Q, Grx.Key.BACK_SPACE,
                                    Grx.Key.ESCAPE):
                self.quit()
        elif t in (Grx.EventType.BUTTON_PRESS, Grx.EventType.BUTTON_RELEASE):
            button_event = event.button
            print("button", button_event.button)
            print("modifiers", button_event.modifiers)
            Grx.clear_screen(Grx.color_get_black())
        elif t == Grx.EventType.BUTTON_DOUBLE_PRESS:
            button_event = event.button
            print("button double-press", button_event.button)
            print("modifiers", button_event.modifiers)
        elif t == Grx.EventType.TOUCH_DOWN:
            touch_event = event.touch
            Grx.draw_pixel(touch_event.x, touch_event.y, self.color)
            self.last_touch = (touch_event.x, touch_event.y)
            print("touch", touch_event.x, touch_event.y)
            print("modifiers", touch_event.modifiers)
        elif t == Grx.EventType.TOUCH_MOTION:
            touch_event = event.touch
            Grx.draw_line(self.last_touch[0], self.last_touch[1],
                          touch_event.x, touch_event.y, self.color)
            self.last_touch = (touch_event.x, touch_event.y)
        else:
            return False

        return True
コード例 #5
0
ファイル: input.py プロジェクト: ev3dev/grx
    def do_event(self, event):
        if Grx.Application.do_event(self, event):
            return True

        t = event.type
        if t in (Grx.EventType.KEY_DOWN, Grx.EventType.KEY_UP):
            key_event = event.key
            print("key keysym", key_event.keysym)
            print("key unichar", key_event.unichar)
            print("key code", key_event.code)
            print("modifiers", key_event.modifiers)
            if key_event.keysym in (Grx.Key.LCASE_Q, Grx.Key.BACK_SPACE, Grx.Key.ESCAPE):
                self.quit()
        elif t in (Grx.EventType.BUTTON_PRESS, Grx.EventType.BUTTON_RELEASE):
            button_event = event.button
            print("button", button_event.button)
            print("modifiers", button_event.modifiers)
            Grx.clear_screen(Grx.color_get_black())
        elif t == Grx.EventType.BUTTON_DOUBLE_PRESS:
            button_event = event.button
            print("button double-press", button_event.button)
            print("modifiers", button_event.modifiers)
        elif t == Grx.EventType.TOUCH_DOWN:
            touch_event = event.touch
            Grx.draw_pixel(touch_event.x, touch_event.y, self.color)
            self.last_touch = (touch_event.x, touch_event.y)
            print("touch", touch_event.x, touch_event.y)
            print("modifiers", touch_event.modifiers)
        elif t == Grx.EventType.TOUCH_MOTION:
            touch_event = event.touch
            Grx.draw_line(self.last_touch[0], self.last_touch[1], touch_event.x, touch_event.y, self.color)
            self.last_touch = (touch_event.x, touch_event.y)
        else:
            return False

        return True