Ejemplo n.º 1
0
 def __init__(self, **kwargs):
     self.dpi = kwargs.pop('dpi')
     super(MemoryTable, self).__init__(**kwargs)
     self.viewclass = 'Label'
     self.recycle_grid_layout = self.children[0]
     if self.dpi < 192:
         self.pos_hint = {'x': dp(0.75), 'center_y': dp(0.75)}
         self.size_hint_x = dp(0.3)
         self.size_hint_y = dp(0.5)
         self.recycle_grid_layout.default_size_hint = (dp(0.5), None)
         self.recycle_grid_layout.size_hint_x = dp(0.83)
         with self.children[0].canvas.before:
             Color(.50, .50, .50, 1)
             for i in range(2049):
                 Line(width=2,
                      rectangle=(dp(0), dp(0), dp(255),
                                 dp(61470 - (30 * i))))
             Line(width=2, rectangle=(dp(0), dp(0), dp(127.5), dp(61470)))
     else:
         self.pos_hint = {'x': dp(0.37), 'center_y': dp(0.368)}
         self.size_hint_x = dp(0.135)
         self.size_hint_y = dp(0.265)
         self.recycle_grid_layout.default_size_hint = (dp(0.5), None)
         self.recycle_grid_layout.size_hint_x = dp(0.47)
         with self.children[0].canvas.before:
             Color(.50, .50, .50, 1)
             for i in range(2049):
                 Line(width=2,
                      rectangle=(dp(0), dp(0), dp(270),
                                 dp(61470 - (30 * i))))
             Line(width=2, rectangle=(dp(0), dp(0), dp(135), dp(61470)))
Ejemplo n.º 2
0
 def __init__(self, **kwargs):
     self.dpi = kwargs.pop('dpi')
     super(RegisterTable, self).__init__(**kwargs)
     self.viewclass = 'Label'
     self.recycle_grid_layout = self.children[0]
     if self.dpi < 192:
         self.pos_hint = {'x': dp(0), 'center_y': dp(0.75)}
         self.size_hint_x = dp(0.2)
         self.size_hint_y = dp(0.5)
         with self.children[0].canvas.before:
             Color(.50, .50, .50, 1)
             for i in range(13):
                 Line(width=2,
                      rectangle=(dp(0), dp(0), dp(205), dp(390 - (30 * i))))
             Line(width=2, rectangle=(dp(0), dp(0), dp(102.5), dp(390)))
     else:
         self.pos_hint = {'x': dp(0), 'center_y': dp(0.368)}
         self.size_hint_x = dp(0.12)
         self.size_hint_y = dp(0.265)
         self.recycle_grid_layout.size_hint_x = dp(0.47)
         with self.children[0].canvas.before:
             Color(.50, .50, .50, 1)
             for i in range(13):
                 Line(width=2,
                      rectangle=(dp(0), dp(0), dp(245), dp(390 - (30 * i))))
             Line(width=2, rectangle=(dp(0), dp(0), dp(115), dp(390)))
 def set_state(self, *args):
     if self.state == 'down':
         with self.canvas.before:
             Color(50 / 255.0, 164 / 255.0, 206 / 255.0,
                   1)  # Button down colour
             Rectangle(pos=self.pos, size=self.size)
             Color(111 / 255.0, 111 / 255.0, 111 / 255.0,
                   1)  # Button hover outline colour
             Line(rectangle=(self.x + 1, self.y + 1, self.width - 1,
                             self.height - 1),
                  width=1)
     else:
         if self.hovered:
             with self.canvas.before:
                 Color(88 / 255.0, 88 / 255.0, 88 / 255.0,
                       1)  # Button hover colour
                 Rectangle(pos=self.pos, size=self.size)
                 Color(111 / 255.0, 111 / 255.0, 111 / 255.0,
                       1)  # Button hover outline colour
                 Line(rectangle=(self.x + 1, self.y + 1, self.width - 1,
                                 self.height - 1),
                      width=1)
         else:
             with self.canvas.before:  # Button up colour
                 Color(53 / 255.0, 53 / 255.0, 53 / 255.0, 1)
                 Rectangle(pos=self.pos, size=self.size)
Ejemplo n.º 4
0
    def draw_field(self):
        with self.canvas.before:
            Color(0.992, 0.925, 0.863, 1)
            Rectangle(pos=self.engine.screen_utils.start,
                      size=self.engine.screen_utils.size)

        self.grid = InstructionGroup()
        points = self.engine.screen_utils.create_grid()
        self.grid.add(Color(rgba=(0.29, 0, 0.153, 1)))
        for a, b in points:
            self.grid.add(Line(points=[a[0], a[1], b[0], b[1]]))

        border_width = 5
        dl = self.engine.screen_utils.start
        width, height = self.engine.screen_utils.size
        self.grid.add(
            Line(points=[
                dl[0] - border_width, dl[1] - border_width,
                dl[0] - border_width, dl[1] + height + border_width,
                dl[0] + width + border_width, dl[1] + height + border_width,
                dl[0] + width + border_width, dl[1] - border_width
            ],
                 width=border_width,
                 close=True))
        self.canvas.before.add(self.grid)
Ejemplo n.º 5
0
 def btn_click_nine(self):
     print("nine")
     with self.canvas:
         Color(1, 0, 0)
         Line(rectangle=(350, 150, 100, 100))
         Color(1, 1, 0, 3)
         Line(rectangle=(50, 150, 100, 100))
Ejemplo n.º 6
0
    def fill_canvas(self):
        from kivy.graphics.context_instructions import Color
        from kivy.graphics.vertex_instructions import Line

        self.normal_level_label = Label(text="100% ",
                                        bold=True,
                                        halign='right',
                                        valign='bottom',
                                        size=(self.LABEL_SIZE,
                                              self.LABEL_SIZE),
                                        text_size=(self.LABEL_SIZE,
                                                   self.LABEL_SIZE))

        self.half_level_label = Label(text="50% ",
                                      bold=True,
                                      halign='right',
                                      valign='bottom',
                                      size=(self.LABEL_SIZE, self.LABEL_SIZE),
                                      text_size=(self.LABEL_SIZE,
                                                 self.LABEL_SIZE))

        self.add_widget(self.normal_level_label)
        self.add_widget(self.half_level_label)

        with self.canvas.before:
            self.fill_color = Color()

        with self.canvas.after:
            Color(1, 1, 1, 1)
            self.normal_level_line = Line(width=dp(2))
            self.half_level_line = Line(width=dp(2))
Ejemplo n.º 7
0
    def draw_stone(self,
                   x,
                   y,
                   col,
                   outline_col=None,
                   innercol=None,
                   evalcol=None,
                   evalscale=1.0,
                   scale=1.0):
        stone_size = self.stone_size * scale
        draw_circle((self.gridpos_x[x], self.gridpos_y[y]), stone_size, col)
        if outline_col:
            Color(*outline_col)
            Line(circle=(self.gridpos_x[x], self.gridpos_y[y], stone_size),
                 width=min(2, 0.035 * stone_size))
        if evalcol:
            eval_radius = math.sqrt(evalscale)  # scale area by evalscale
            evalsize = self.stone_size * (
                self.ui_config["eval_dot_min_size"] + eval_radius *
                (self.ui_config["eval_dot_max_size"] -
                 self.ui_config["eval_dot_min_size"]))
            draw_circle((self.gridpos_x[x], self.gridpos_y[y]), evalsize,
                        evalcol)

        if innercol:
            Color(*innercol)
            Line(circle=(self.gridpos_x[x], self.gridpos_y[y],
                         stone_size * 0.475 / 0.85),
                 width=0.1 * stone_size)
Ejemplo n.º 8
0
 def btn_click_seven(self):
     print("seven")
     with self.canvas:
         Color(1, 0, 0)
         Line(rectangle=(50, 150, 100, 100))
         Color(1, 1, 0, 3)
         Line(rectangle=(50, 300, 100, 100))
Ejemplo n.º 9
0
 def btn_click_eight(self):
     print("eigth")
     with self.canvas:
         Color(1, 0, 0)
         Line(rectangle=(200, 150, 100, 100))
         Color(1, 1, 0, 3)
         Line(rectangle=(200, 300, 100, 100))
Ejemplo n.º 10
0
    def change(self, instance):

        if instance.text == 'x' or instance.text == 'o':
            return None

        padding_draw = 10

        draw_symbol = self.symbol.__next__()
        if draw_symbol == 'x':
            with instance.canvas:
                Line(points=(instance.x + padding_draw, instance.y + padding_draw,
                             instance.x + instance.width - padding_draw, instance.y + instance.height - padding_draw),
                      width=3)
                Line(points=(instance.x + instance.width - padding_draw, instance.y + padding_draw,
                             instance.x + padding_draw, instance.y + instance.height - padding_draw),
                      width=3)

        else:
            with instance.canvas:
                Line(circle=(instance.center_x, instance.center_y, min(instance.width, instance.height)/2 - padding_draw),
                     width=3)

        if instance in self.children:
            self.cells[self.children.index(instance)] = draw_symbol
            instance.text = draw_symbol

        self.find_winner()
Ejemplo n.º 11
0
 def btn_click_second(self):
     print("second")
     with self.canvas:
         Color(1, 0, 0)
         Line(rectangle=(200, 450, 100, 100))
         Color(1, 1, 0, 3)
         Line(rectangle=(200, 150, 100, 100))
Ejemplo n.º 12
0
 def btn_click_four(self):
     print("four")
     with self.canvas:
         Color(1, 0, 0)
         Line(rectangle=(50, 300, 100, 100))
         Color(1, 1, 0, 3)
         Line(rectangle=(350, 300, 100, 100))
Ejemplo n.º 13
0
 def btn_click_third(self):
     print("third")
     with self.canvas:
         Color(1, 0, 0, 3)
         Line(rectangle=(350, 450, 100, 100))
         Color(1, 1, 0, 3)
         Line(rectangle=(50, 450, 100, 100))
Ejemplo n.º 14
0
 def update(self, dt):
     self.temps += FREQ
     self.canvas.clear()
     # Dessin du cadre
     with self.canvas:
         Color(1, 1, 1)
         Line(rectangle=(0, 0, self.L, self.H), width=2)
     self.remove_widget(self.label_titre)
     self.add_widget(self.label_titre)
     self.chart_unit()
     # Trace la courbe
     pas = int(300/10*FREQ)
     max_graph = int(10 / FREQ)
     for i in range(0, max_graph-1):
         x1 = self.graphX[i]
         y1 = self.graphY[i]
         x2 = self.graphX[i + 1]
         y2 = self.graphY[i + 1]
         with self.canvas:
             Color(0, 1, 1)
             Line(points=(x1, y1, x2, y2))
     # mise à jour des points avec intégration de la nouvelle valeur
     # à la fin
     for i in range(0, max_graph-1):
         self.graphY[i] = self.graphY[i + 1]
     # Mise à jour de de la valeur du capteur
     self.graphY[max_graph-1] = self.capteur.data
Ejemplo n.º 15
0
 def btn_click_five(self):
     print("five")
     with self.canvas:
         Color(1, 0, 0)
         Line(rectangle=(200, 300, 100, 100))
         Color(1, 1, 0, 3)
         Line(rectangle=(200, 450, 100, 100))
Ejemplo n.º 16
0
        def repaint(self, *args):
            self.canvas.clear()
            w = 5
            with self.canvas:
                Color(1, 1, 1, 1)
                Line(points=(self.pos[0], self.pos[1], self.pos[0],
                             self.pos[1] + self.height),
                     width=w,
                     cap='none')
                Line(points=(self.pos[0] + self.width, self.pos[1],
                             self.pos[0] + self.width,
                             self.pos[1] + self.height),
                     width=w,
                     cap='none')

                y = self.pos[1] + self.height / 2
                x = self.pos[0] + w * 2
                for i in range(floor(self.width / (4 * w))):
                    Line(points=(x + i * 4 * w, y, x + (i * 4 + 2) * w, y),
                         width=w,
                         cap='none')

                # cursor
                Color(1, 0, 0, 1)
                x = self.pos[0] + self.value * self.width
                y0 = self.pos[1] + 0.05 * self.height
                y1 = self.pos[1] + 0.95 * self.height
                Line(points=(x, y0, x, y1), width=w // 2, cap='none')
Ejemplo n.º 17
0
    def draw_stone(self,
                   x,
                   y,
                   col,
                   outline_col=None,
                   innercol=None,
                   evalcol=None,
                   evalscale=1.0,
                   scale=1.0):
        stone_size = self.stone_size * scale
        draw_circle((self.gridpos_x[x], self.gridpos_y[y]), stone_size, col)
        if outline_col:
            Color(*outline_col)
            Line(circle=(self.gridpos_x[x], self.gridpos_y[y], stone_size),
                 width=min(2, 0.035 * stone_size))
        if evalcol:
            eval_radius = math.sqrt(evalscale)  # scale area by evalscale
            evalsize = self.stone_size * (
                EVAL_DOT_MIN_SIZE + eval_radius *
                (EVAL_DOT_MAX_SIZE - EVAL_DOT_MIN_SIZE))
            draw_circle((self.gridpos_x[x], self.gridpos_y[y]), evalsize,
                        evalcol)

        if innercol:
            Color(*innercol)
            Line(circle=(self.gridpos_x[x], self.gridpos_y[y],
                         stone_size * 0.475 / 0.85),
                 width=0.1 * stone_size)
Ejemplo n.º 18
0
 def __init__(self, app):
     super(World, self).__init__()
     self.size_hint = None, None
     self.size = SIZE
     self.pos_hint = {'center': (.5, 5)}
     self.hive = None
     self.rocks = []
     self.add_ground()
     w, h = SIZE
     with self.canvas:
         ground_fbo = Fbo(size=self.size)
         Rectangle(pos=(0, 0),
                   size=(w * 2, h * 2),
                   texture=ground_fbo.texture)
         Rectangle(pos=(0, 0), size=(w * 2, h * 2), texture=app.texture)
         Rectangle(pos=(0, 0),
                   size=(w * 2, h * 2),
                   texture=app.returning_paths_texture)
     with ground_fbo:
         Color(*STONE_COLOR_FLOAT)
         Line(rectangle=[0, 0, w, h], width=4)
         for rock in self.rocks:
             Line(points=rock.points, close=False, width=4)
         ground_fbo.draw()
     turn_to_world_array(ground_fbo.texture.pixels)
     self.populate()
Ejemplo n.º 19
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     with self.canvas:
         Line(points=(100, 100, 400, 500), width=2)
         Color(0, 1, 0)
         Line(circle=(400, 200, 80), width=2)
         Line(rectangle=(700, 500, 150, 100), width=5)
         self.rect = Rectangle(pos=(700, 200), size=(150, 100))
Ejemplo n.º 20
0
    def btn_click_first(self):
        print("first")
        with self.canvas:
            Color(1, 0, 0, 3)
            Line(rectangle=(50, 450, 100, 100))

            Color(1, 1, 0, 3)
            Line(rectangle=(350, 450, 100, 100))
Ejemplo n.º 21
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     with self.canvas:
         Line(points=(100, 100, 400, 500), width=2)
         Color(0, 1, 0)
         Line(circle=(400, 200, 80), width=2)
         Line(rectangle=(500, 300, 150, 100), width=5)
         # create instance of rectangle for move_rect()
         self.rect = Rectangle(pos=(500, 100), size=(150, 100))
Ejemplo n.º 22
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        with self.canvas:
            Line(points=(100, 100, 240, 250))
            Color(0, 1, 1, 0.5)
            self.square = Rectangle(pos=(0, 100), size=(100, 100))
            Color(1, 0, 1, 1)
            Line(circle=(100, 100, 250), width=3)
Ejemplo n.º 23
0
    def __init__(self, **kwargs):
        super(StartOperationScreen, self).__init__(**kwargs)

        with self.canvas.before:
            Color(255, 255, 255, 255)
            Line(points=[55, 75, 55, 1100], close=True, width=1)
            Line(points=[1550, 75, 1550, 1100], close=True, width=1)
            Line(points=[1550, 75, 55, 75], close=True, width=1)
            Line(points=[1550, 1100, 55, 1100], close=True, width=1)
Ejemplo n.º 24
0
    def __init__(self, **kwargs):
        super(WelcomeScreen, self).__init__(**kwargs)

        # draw border (eventually this should be in a loop for each screen)
        with self.canvas.before:
            Color(255, 255, 255, 255)
            Line(points=[55, 75, 55, 1100], close=True, width=1)
            Line(points=[1550, 75, 1550, 1100], close=True, width=1)
            Line(points=[1550, 75, 55, 75], close=True, width=1)
            Line(points=[1550, 1100, 55, 1100], close=True, width=1)
Ejemplo n.º 25
0
    def redraw(self, *args):
        # self.update()
        self.canvas.clear()
        if not self.visible:
            return

        self.pos = self.owner.pos
        self.size = self.owner.size

        width = self.owner.texture.size[0]
        height = self.owner.texture.size[1]

        h_stride = self.width / width
        v_stride = self.height / height

        if h_stride < 8 or v_stride < 8:
            return

        grid = InstructionGroup()

        startx = int(-self.owner.pos[0] / h_stride)
        if startx < 0:
            startx = 0

        starty = int(-self.owner.pos[1] / v_stride)
        if starty < 0:
            starty = 0

        endx = int(self.viewer.size[0] / h_stride + startx + 2)
        endy = int(self.viewer.size[1] / v_stride + starty + 2)
        if endy >= height + 1:
            endy = height + 1

        if endx >= width + 1:
            endx = width + 1

        grid.add(Color(1, 1, 1))
        for y in range(starty, endy):
            grid.add(
                Line(points=[
                    int(self.x + 0),
                    int(self.y + y * v_stride),
                    int(self.x + self.width),
                    int(self.y + y * v_stride)
                ]))
        for x in range(startx, endx):
            grid.add(
                Line(points=[
                    int(self.x + x * h_stride),
                    int(self.y + 0),
                    int(self.x + x * h_stride),
                    int(self.y + self.height)
                ]))

        self.canvas.add(grid)
Ejemplo n.º 26
0
 def _paint_gridlines(self):
     if self.gridlines:
         self.canvas.remove(self.gridlines)
     self.gridlines = InstructionGroup()
     self.gridlines.add(Color(1, 1, 1))
     for line in range(0, self.rows + 1):
         x = self.grid_properties.cell_width * line
         y = self.grid_properties.cell_height * line
         self.gridlines.add(Line(points=((x, 0), (x, self.height))))
         self.gridlines.add(Line(points=((0, y), (self.width, y))))
     self.canvas.add(self.gridlines)
    def __init__(self, **kwargs):
        super(NewsWidget, self).__init__(**kwargs)
        self.rss_service = RSSService()
        logger.info("Initialized NewsWidget")

        with self.canvas:
            Color(0.15, 0.15, 0.15, .4, mode='rgba')
            RoundedRectangle(pos=(0, -200),
                             size=(760, 300),
                             radius=[(5, 5), (5, 5), (5, 5), (5, 5)])
            Color(1, 1, 1, .2, mode='rgba')
            Line(points=[15, 0, 745, 0])
            Line(points=[15, -100, 745, -100])
Ejemplo n.º 28
0
    def __init__(self, **kwargs):
        self.mem_table = kwargs.pop('mem_table')
        self.dpi = kwargs.pop('dpi')
        super(HexKeyboard, self).__init__(**kwargs)
        self.can_write = True
        self.queue = Queue(maxsize=10)
        self.lock = Lock()
        self.semaphore = Semaphore()
        self.condition = Condition()
        if self.dpi < 192:
            self.size_hint = (dp(0.4), dp(0.4))
            self.pos_hint = {'x': dp(0.10), 'y': dp(0.35)}
        else:
            self.size_hint = (dp(0.4), dp(0.2))
            self.pos_hint = {'x': dp(0.105), 'y': dp(0.1232)}

        with self.canvas.before:
            Color(.50, .50, .50, 1)
            Rectangle(pos=(dp(336), dp(249)), size=(dp(362), dp(208)))

        with self.canvas:
            Color(1, 1, 1, 1)
            Rectangle(pos=(dp(340), dp(254)), size=(dp(354), dp(199)))

            Color(.75, .75, .75, 1)
            Rectangle(pos=(dp(340), dp(250)), size=(dp(353), dp(143)))

            Color(.50, .50, .50, 1)
            for i in range(16):
                if i < 4:
                    Line(rectangle=(dp(340 + (89 * (i % 4))), dp(357), dp(87),
                                    dp(35)),
                         width=dp(0.8))
                elif i < 8:
                    Line(rectangle=(dp(340 + (89 * (i % 4))), dp(322), dp(87),
                                    dp(35)),
                         width=dp(0.8))
                elif i < 12:
                    Line(rectangle=(dp(340 + (89 * (i % 4))), dp(287), dp(87),
                                    dp(35)),
                         width=dp(0.8))
                else:
                    Line(rectangle=(dp(340 + (89 * (i % 4))), dp(252), dp(87),
                                    dp(35)),
                         width=dp(0.8))

        for i in range(16):
            if i > 9:
                i = str(chr(i + 55))
            self.add_widget(
                MDFlatButton(text=f'{i}', on_release=self.hex_key_press))
    def __init__(self, **kwargs):
        super(WeatherWidget, self).__init__(**kwargs)
        self.met_service = METService()
        logger.info("Initialized WeatherWidget")

        with self.canvas:
            Color(0.15, 0.15, 0.15, .4, mode='rgba')
            RoundedRectangle(pos=(-25, -25),
                             size=(985, 240),
                             radius=[(5, 5), (5, 5), (5, 5), (5, 5)])
            Color(1, 1, 1, .2, mode='rgba')
            Line(points=[220, 190, 220, 0])
            Line(points=[470, 190, 470, 0])
            Line(points=[720, 190, 720, 0])
Ejemplo n.º 30
0
 def __init__(self, **kwargs):
     self.board = Board()
     super(Grid, self).__init__(**kwargs)
     for i, c in enumerate(self.board.cells):
         xy = self.board.idx_to_xy(i)
         cell = Factory.Cell(i, xy, c)
         cell.bind(value=self._value_changed)
         self.add_widget(cell)
         self.cells[xy] = cell
     with self.canvas:
         Color(0, 0, 0)
         self.lines_h = [Line() for _ in range(8)]
         self.lines_v = [Line() for _ in range(8)]
     self.redraw()
     self.bind(pos=self.redraw, size=self.redraw)