コード例 #1
0
        def draw_crosses(offset_x, offset_y, width, height):
            for row in range(0, 2):
                for col in range(0, 2):
                    cx = offset_x + width / 6 + (col + 0.5) * width / 3
                    cy = offset_y + height / 6 + (row + 0.5) * height / 3

                    canvas.draw_line(cx - 10, cy, cx + 10, cy)
                    canvas.draw_line(cx, cy - 10, cx, cy + 10)
コード例 #2
0
 def draw(self, canvas):
     paint = canvas.paint
     paint.color = "ff0000"
     canvas.draw_line(self.offset_x + self.width / 2, self.offset_y,
                      self.offset_x + self.width / 2,
                      self.offset_y + self.height)
     canvas.draw_line(self.offset_x, self.offset_y + self.height / 2,
                      self.offset_x + self.width,
                      self.offset_y + self.height / 2)
コード例 #3
0
ファイル: mouse_sonar.py プロジェクト: ym-han/talon-user
    def draw(self, canvas):
        paint = canvas.paint
        paint.color = "ff00ff"
        paint.stroke_width = 5
        # print(paint.__dir__())
        now = time.time()
        pos = Point2d(self.radius, 0)
        pos.rot(self.angle)

        ctrl.mouse_move(pos.x, pos.y)
        canvas.draw_line(self.center_x, self.center_y, pos.x, pos.y)
        self.last_draw = now
コード例 #4
0
        def draw_grid(offset_x, offset_y, width, height):
            canvas.draw_line(
                offset_x + width // 3,
                offset_y,
                offset_x + width // 3,
                offset_y + height,
            )
            canvas.draw_line(
                offset_x + 2 * width // 3,
                offset_y,
                offset_x + 2 * width // 3,
                offset_y + height,
            )

            canvas.draw_line(
                offset_x,
                offset_y + height // 3,
                offset_x + width,
                offset_y + height // 3,
            )
            canvas.draw_line(
                offset_x,
                offset_y + 2 * height // 3,
                offset_x + width,
                offset_y + 2 * height // 3,
            )
コード例 #5
0
ファイル: mouse_grid.py プロジェクト: knausj85/MR-talon
        def draw_grid(offset_x, offset_y, width, height):
            one_third_along = offset_x + width // 3
            canvas.draw_line(one_third_along, offset_y, one_third_along,
                             offset_y + height)

            two_thirds_along = offset_x + 2 * width // 3
            canvas.draw_line(two_thirds_along, offset_y, two_thirds_along,
                             offset_y + height)

            one_third_down = offset_y + height // 3
            canvas.draw_line(offset_x, one_third_down, offset_x + width,
                             one_third_down)

            two_thirds_down = offset_y + 2 * height // 3
            canvas.draw_line(offset_x, two_thirds_down, offset_x + width,
                             two_thirds_down)
コード例 #6
0
    def draw_canvas(self, canvas):
        paint = canvas.paint
        paint.color = 'fff'
        rect = canvas.rect

        SMALL_DIST = 5
        SMALL_LENGTH = 10
        LARGE_DIST = 25
        LARGE_LENGTH = 30
        irange = lambda start, stop, step: range(int(start), int(stop),
                                                 int(step))
        paint.antialias = False
        for off, color in ((0, 'ffffffff'), (1, '000000ff')):
            paint.color = color

            # draw axis lines
            cx, cy = rect.center
            cxo = cx + off
            cyo = cy + off

            # draw ticks
            for tick_dist, tick_length in ((SMALL_DIST, SMALL_LENGTH),
                                           (LARGE_DIST, LARGE_LENGTH)):
                half = tick_length // 2
                # ticks to the left
                for x in irange(rect.left + off, cx - tick_dist + 1,
                                tick_dist):
                    canvas.draw_line(x, cy - half, x, cy + half)
                # ticks to the right
                for x in irange(cxo + tick_dist - 1, rect.right + 1,
                                tick_dist):
                    canvas.draw_line(x, cy - half, x, cy + half)
                # ticks above
                for y in irange(rect.top + off + 1, cy - tick_dist + 1,
                                tick_dist):
                    canvas.draw_line(cx - half, y, cx + half, y)
                # ticks below
                for y in irange(cyo + tick_dist, rect.bot + 1, tick_dist):
                    canvas.draw_line(cx - half, y, cx + half, y)
コード例 #7
0
        def draw_crosses():
            for row in range(1, self.rows):
                for col in range(1, self.columns):
                    cx = self.field_size * col
                    cy = self.field_size * row

                    canvas.save()
                    canvas.translate(0.5, 0.5)

                    canvas.draw_line(cx - crosswidth + 0.5, cy,
                                     cx + crosswidth - 0.5, cy)
                    canvas.draw_line(cx, cy + 0.5, cx, cy + crosswidth - 0.5)
                    canvas.draw_line(cx, cy - crosswidth + 0.5, cx, cy - 0.5)

                    canvas.restore()
コード例 #8
0
    def draw(self, canvas):
        paint = canvas.paint
        paint.color = "ff0000"
        canvas.draw_line(self.offset_x + self.width // 3, self.offset_y,
                         self.offset_x + self.width // 3,
                         self.offset_y + self.height)
        canvas.draw_line(self.offset_x + 2 * self.width // 3, self.offset_y,
                         self.offset_x + 2 * self.width // 3,
                         self.offset_y + self.height)

        canvas.draw_line(self.offset_x, self.offset_y + self.height // 3,
                         self.offset_x + self.width,
                         self.offset_y + self.height // 3)
        canvas.draw_line(self.offset_x, self.offset_y + 2 * self.height // 3,
                         self.offset_x + self.width,
                         self.offset_y + 2 * self.height // 3)

        for row in range(3):
            for col in range(3):
                canvas.draw_text(
                    f"{row*3+col+1}",
                    self.offset_x + self.width / 6 + col * self.width / 3,
                    self.offset_y + self.height / 6 + row * self.height / 3)
コード例 #9
0
ファイル: mouse_rc.py プロジェクト: navw/talon-user
    def draw(self, canvas):
        paint = canvas.paint
        paint.color = "ff00ff"
        paint.stroke_width = 5
        # print(paint.__dir__())
        now = time.time()
        elapsed = now - self.last_draw
        hiss_dt = now - self.hiss_start
        c = cos(self.angle)
        s = sin(self.angle)
        delta = Point2d(self.speed * c, self.speed * s)
        # print(delta)
        delta = delta.apply(self.accel, hiss_dt / 100)
        # print(delta)
        self.offset_x += delta.x
        if self.offset_x < 0:
            self.offset_x = 0
        elif self.offset_x > self.main_screen.width:
            self.offset_x = self.main_screen.width
        self.offset_y += delta.y
        if self.offset_y < 0:
            self.offset_y = 0
        elif self.offset_y > self.main_screen.height:
            self.offset_y = self.main_screen.height
        ctrl.mouse_move(self.offset_x, self.offset_y)
        line1 = self.rotate(c, s, 0, 0, -2 * SIZE, SIZE)
        line2 = self.rotate(c, s, 0, 0, -2 * SIZE, -SIZE)
        line3 = (line1[2], line1[3], line2[2], line2[3])

        canvas.draw_line(self.offset_x + line1[0], self.offset_y + line1[1],
                         self.offset_x + line1[2], self.offset_y + line1[3])
        canvas.draw_line(self.offset_x + line2[0], self.offset_y + line2[1],
                         self.offset_x + line2[2], self.offset_y + line2[3])
        canvas.draw_line(self.offset_x + line3[0], self.offset_y + line3[1],
                         self.offset_x + line3[2], self.offset_y + line3[3])
        self.last_draw = now
コード例 #10
0
    def draw_setup_mode(self, canvas) -> skia.Paint:
        """Implements drawing the dimension lines when resizing elements"""
        paint = canvas.paint
        if self.setup_type in ["dimension", "limit", "position"]:
            # Colours blue and red chosen for contrast and decreased possibility of colour blindness making it difficult
            # To make out the width and the limit lines
            paint.color = '0000AA'
            resize_margin = 2
            leftmost = self.x + resize_margin
            rightmost = self.x + self.width - resize_margin
            topmost = self.y + resize_margin
            bottommost = self.y + self.height - resize_margin
            canvas.draw_line(leftmost, topmost, rightmost, topmost)
            canvas.draw_line(rightmost, topmost, rightmost, bottommost)
            canvas.draw_line(rightmost, bottommost, leftmost, bottommost)
            canvas.draw_line(leftmost, bottommost, leftmost, topmost)

            paint.color = 'FF0000'
            resize_margin = 0
            leftmost = self.limit_x + resize_margin
            rightmost = self.limit_x + self.limit_width - resize_margin
            topmost = self.limit_y + resize_margin
            bottommost = self.limit_y + self.limit_height - resize_margin
            canvas.draw_line(leftmost, topmost, rightmost, topmost)
            canvas.draw_line(rightmost, topmost, rightmost, bottommost)
            canvas.draw_line(rightmost, bottommost, leftmost, bottommost)
            canvas.draw_line(leftmost, bottommost, leftmost, topmost)
        return paint