示例#1
0
def create_lines_with_colors(point_list: PointList,
                             color_list: Sequence[Color],
                             line_width: float = 1):

    if line_width == 1:
        return create_line_generic_with_colors(point_list, color_list,
                                               gl.GL_LINES, line_width)
    else:

        triangle_point_list = []
        new_color_list = []
        for i in range(1, len(point_list), 2):
            start_x = point_list[i - 1][0]
            start_y = point_list[i - 1][1]
            end_x = point_list[i][0]
            end_y = point_list[i][1]
            color1 = color_list[i - 1]
            color2 = color_list[i]
            points = _get_points_for_thick_line(start_x, start_y, end_x, end_y,
                                                line_width)
            new_color_list += color1, color1, color2, color2
            triangle_point_list += points[1], points[0], points[2], points[3]

            shape = create_triangles_filled_with_colors(
                triangle_point_list, new_color_list)
            return shape
示例#2
0
def create_line(start_x: float,
                start_y: float,
                end_x: float,
                end_y: float,
                color: Color,
                line_width: float = 1) -> Shape:
    """
    Create a line to be rendered later. This works faster than draw_line because
    the vertexes are only loaded to the graphics card once, rather than each frame.

    :param float start_x:
    :param float start_y:
    :param float end_x:
    :param float end_y:
    :param Color color:
    :param float line_width:

    :Returns Shape:

    """

    points = _get_points_for_thick_line(start_x, start_y, end_x, end_y,
                                        line_width)
    color_list = [color, color, color, color]
    triangle_point_list = points[1], points[0], points[2], points[3]
    shape = create_triangles_filled_with_colors(triangle_point_list,
                                                color_list)
    return shape
示例#3
0
def create_line_strip(point_list: PointList,
                      color: Color,
                      line_width: float = 1):
    """
    Create a multi-point line to be rendered later. This works faster than draw_line because
    the vertexes are only loaded to the graphics card once, rather than each frame.

    :param PointList point_list:
    :param Color color:
    :param PointList line_width:

    :Returns Shape:

    """
    if line_width == 1:
        return create_line_generic(point_list, color, gl.GL_LINE_STRIP,
                                   line_width)
    else:
        triangle_point_list = []
        new_color_list = []
        for i in range(1, len(point_list)):
            start_x = point_list[i - 1][0]
            start_y = point_list[i - 1][1]
            end_x = point_list[i][0]
            end_y = point_list[i][1]
            color1 = color
            color2 = color
            points = _get_points_for_thick_line(start_x, start_y, end_x, end_y,
                                                line_width)
            new_color_list += color1, color2, color1, color2
            triangle_point_list += points[1], points[0], points[2], points[3]

            shape = create_triangles_filled_with_colors(
                triangle_point_list, new_color_list)
            return shape