Drawing Functions¶
The art._drawing submodule contains functions to draw something on an Art.
- pygamecv.draw.arc(surface: Surface, center: tuple[int, int], radius_x: int, radius_y: int, color: Color, thickness: int, antialias: bool, angle: int, start_angle: int, end_angle: int)¶
Draw an arc following an ellipse on an pygame.Surface using cv.
Params:¶
surface: pygame.Surface, the surface on which the arc is drawn.
center: tuple[int, int], the center of the elliptical arc on the surface.
radius_x: int, the horizontal (before rotation) semi-major axis of the ellipse.
radius_y: int, the vertical (before rotation) semi-minor axis of the ellipse.
color: pygame.Color, the color of the arc.
thickness: int, the thickness of the draw. If thickness == 0, the arc is filled like a pie, else, it is a thick line.
antialias: bool, specify whether the drawing should use antialiased lines or not.
angle: int, in degrees, the angle by which the axis-aligned ellipse will be rotated.
start_angle: int, in degrees, the angle to start drawing.
end_angle: int, in degress, the angle to stop drawing.
The arc is drawn clockwise from start_angle to end_angle.
- pygamecv.draw.circle(surface: Surface, center: tuple[int, int], radius: int, color: Color, thickness: int, antialias: bool)¶
Draw a circle on an pygame.Surface using cv.
Params:¶
surface: pygame.Surface, the surface on which the circle is drawn.
center: tuple[int, int], the center of the circle on the surface.
radius: int, the radius of the circle
color: pygame.Color, the color of the circle.
thickness: int, the thickness of the draw. If thickness == 0, the circle is filled, else, it is a thick line.
antialias: bool, specify whether the drawing should use antialiased lines or not.
- pygamecv.draw.ellipse(surface: Surface, center: tuple[int, int], radius_x: int, radius_y: int, color: Color, thickness: int, antialias: bool, angle: int = 0)¶
Draw an ellipse on an pygame.Surface using cv.
Params:¶
surface: pygame.Surface, the surface on which the ellipse is drawn.
center: tuple[int, int], the center of the ellipse on the surface.
radius_x: int, the horizontal (before rotation) semi-major axis.
radius_y: int, the vertical (before rotation) semi-minor axis.
color: pygame.Color, the color of the ellipse.
thickness: int, the thickness of the draw. If thickness == 0, the ellipse is filled, else, it is a thick line.
antialias: bool, specify whether the drawing should use antialiased lines or not.
angle: int, in degrees, the angle by which the axis-aligned ellipse will be rotated.
- pygamecv.draw.line(surface: Surface, p1: tuple[int, int], p2: tuple[int, int], color: Color, thickness: int, antialias: bool)¶
Draw a line on a pygame.Surface using cv.
Params:¶
surface: pygame.Surface, the surface on which the line is drawn.
p1: tuple[int, int], the position of the starting point of the line.
p2: tuple[int, int], the position of the ending point of the line.
color: pygame.Color, the color of the line.
thickness: int, the thickness of the draw. If thickness == 0, nothing is drawn.
antialias: bool, specify whether the line should be antialiased or not.
- pygamecv.draw.lines(surface: Surface, points: list[tuple[int, int]], color: Color, thickness: int, antialias: bool, closed: bool)¶
Draw several lines on a pygame.Surface using cv. It is faster than drawing multiple lines one by one.
Params:¶
surface: pygame.Surface, the surface on which the line is drawn.
points: Sequence[tuple[int, int]], the succesive points to be link by a line.
color: pygame.Color, the color of the line.
thickness: int, the thickness of the draw. If thickness == 0, nothing is drawn.
antialias: bool, specify whether the line should be antialiased or not.
closed: bool, if True, the first and last points are linked with a line.
- pygamecv.draw.pie(surface: Surface, center: tuple[int, int], radius_x: int, radius_y: int, color: Color, thickness: int, antialias: bool, angle: int, start_angle: int, end_angle: int)¶
Draw a pie following an ellipse on an pygame.Surface using cv. A pie is an arc where the start and end points are linked to the center of the ellipse.
Params:¶
surface: pygame.Surface, the surface on which the pie is drawn.
center: tuple[int, int], the center of the elliptical pie on the surface.
radius_x: int, the horizontal (before rotation) semi-major axis of the ellipse.
radius_y: int, the vertical (before rotation) semi-minor axis of the ellipse.
color: pygame.Color, the color of the pie.
thickness: int, the thickness of the draw. If thickness == 0, the pie is filled, else, it is a thick line.
antialias: bool, specify whether the drawing should use antialiased lines or not.
angle: int, in degrees, the angle by which the axis-aligned ellipse will be rotated.
start_angle: int, in degrees, the angle to start drawing.
end_angle: int, in degress, the angle to stop drawing.
The pie’s arc is drawn clockwise from start_angle to end_angle.
- pygamecv.draw.polygon(surface: Surface, points: list[tuple[int, int]], color: Color, thickness: int, antialias: bool)¶
Draw a polygon on a pygame.Surface using cv.
Params:¶
surface: pygame.Surface, the surface on which the line is drawn.
points: Sequence[tuple[int, int]], the succesive vertices of the polygon.
color: pygame.Color, the color of the line.
thickness: int, the thickness of the draw. If thickness == 0, the polygon is filled
antialias: bool, specify whether the line should be antialiased or not.
closed: bool, if True, the first and last points are linked with a line.
- pygamecv.draw.rectangle(surface: Surface, rect: Rect, color: Color, thickness: int)¶
Draw a rectangle on a pygame.Surface using cv.
Params:¶
surface: pygame.Surface, the surface on which the line is drawn.
rect: pygame.Rect, the rectangle representing the center line of the drawing (the drawing is extended in case of thickness)
color: pygame.Color, the color of the line.
thickness: int, the thickness of the draw. If thickness == 0, the rectangle is filled, else, it is a thick line.
antialias: bool, specify whether the line should be antialiased or not.
- pygamecv.draw.rounded_rectangle(surface: Surface, rect: Rect, color: Color, thickness: int, antialias: bool, top_left: int, top_right: int = None, bottom_left: int = None, bottom_right: int = None)¶
Draw a rectangle with rounded corners on a pygame.Surface using cv.
Params:¶
surface: pygame.Surface, the surface on which the line is drawn.
rect: pygame.Rect, the rectangle representing the center line of the drawing (the drawing is extended in case of thickness)
color: pygame.Color, the color of the line.
thickness: int, the thickness of the draw. If thickness == 0, the rectangle is filled, else, it is a thick line.
antialias: bool, specify whether the line should be antialiased or not.
top_left: int, the radius of the top left corner.
top_right: int | None = None, the radius of the top right corner. If None, uses the same value as the top left corner.
bottom_left: int | None = None, the radius of the bottom left corner. If None, uses the same value as the top left corner.
bottom_right: int | None = None, the radius of the bottom right corner. If None, uses the same value as the top left corner.