Пример #1
0
def create_refresh_button():
    button_area = shapes.Rectangle(0, 0, 30, 30)
    button = rendering.Button(button_area)
    points = []
    dy = None
    y = 0
    for angle in range(0, 270, 15):
        point_outer = (-math.sin(math.radians(angle)) * 9,
                       -math.cos(math.radians(angle)) * 9)
        point_inner = (-math.sin(math.radians(angle)) * 7,
                       -math.cos(math.radians(angle)) * 7)
        points.append(point_outer)
        points.insert(0, point_inner)
        if dy is None:
            dy = (point_outer[1] - point_inner[1])
            y = (point_outer[1] + point_inner[1]) / 2
    polygon_points = [(5, y), (0, y + 5), (0, y - 5)]
    arrow = shapes.Polygon(polygon_points)
    open_circle = shapes.Polygon(points)
    shape_graphic = rendering.SimpleMonoColouredGraphic(
        open_circle, colours.GREEN)
    arrow_graphic = rendering.SimpleMonoColouredGraphic(arrow, colours.GREEN)
    old_pos = (open_circle.left, open_circle.down)
    button.add_and_center_canvas(shape_graphic)
    new_pos = (open_circle.left, open_circle.down)
    arrow.translate([x - y for x, y in zip(new_pos, old_pos)])
    button.add_canvas(arrow_graphic)

    return button
Пример #2
0
def create_play_button():
    button_area = shapes.Rectangle(0, 0, 30, 30)
    button_icon = shapes.Polygon([(6, 0), (-6, -10), (-6, 10)])
    # self.button_graphic_background = rendering.SimpleMonoColouredGraphic(button_rect_background, )
    button_graphic_icon = rendering.SimpleMonoColouredGraphic(
        button_icon, colours.GREEN)
    button = rendering.Button(button_area)
    button.add_and_center_canvas(button_graphic_icon)
    return button
Пример #3
0
def create_pause_button():
    button_area = shapes.Rectangle(0, 0, 30, 30)
    button = rendering.Button(button_area)
    for x in (-4, 4):
        button_icon_left = shapes.Rectangle(0, 0, 6, 20)
        button_graphic_icon = rendering.SimpleMonoColouredGraphic(
            button_icon_left, colours.grey(100))
        button.add_and_center_canvas(button_graphic_icon)
        button_graphic_icon.translate((x, 0))
    return button
Пример #4
0
def create_time_warp_button(increase):
    button = rendering.RectangularButton((30, 30))
    c = 1 if increase else -1
    for dx in [-5, 5]:
        button_icon = shapes.Polygon([(3 * c, 0), (-3 * c, -10), (-3 * c, 10)])
        # self.button_graphic_background = rendering.SimpleMonoColouredGraphic(button_rect_background, )
        button_graphic = rendering.SimpleMonoColouredGraphic(
            button_icon, colours.GREEN)
        button.add_and_center_canvas(button_graphic)
        button_graphic.translate((dx, 0))
    return button
Пример #5
0
def create_visualise_bounding_button():
    button_area = shapes.Rectangle(0, 0, 30, 30)
    button = rendering.Button(button_area)
    icon_shapes = [
        shapes.Circle((8, 10), 7),
        shapes.LineSegment((5, 28), (28, 18))
    ]
    for shape in icon_shapes:
        if shape.has_area():
            shape_graphic = rendering.SimpleMonoColouredGraphic(
                shape, colours.BLUE)
        else:
            shape_graphic = rendering.SimpleOutlineGraphic(shape, colours.BLUE)
        button.add_canvas(shape_graphic)
        button.add_canvas(
            rendering.SimpleOutlineGraphic(shape.to_bounding_rectangle(),
                                           colours.RED))

    return button