Exemple #1
0
class DrawText(DrawCommand):
    """Draws text."""

    pos: Tuple[float, float] = DrawPropertyPos2D()
    text: str = DrawProperty()

    color: ColorRGBA = DrawPropertyColorRGBA()
    font_size: int = DrawProperty(key='size')

    def __draw_internal__(self, draw_args) -> None:
        dpgcore.draw_text(self.canvas.id, tag=self.id, **draw_args)
Exemple #2
0
class DrawArrow(DrawCommand):
    """Draw a line with an arrowhead."""

    p1: Tuple[float, float] = DrawPropertyPos2D()
    p2: Tuple[float, float] = DrawPropertyPos2D()
    color: ColorRGBA = DrawPropertyColorRGBA()
    thickness: int = DrawProperty()
    arrow_size: int = DrawProperty(key='size')

    def __draw_internal__(self, draw_args) -> None:
        dpgcore.draw_arrow(self.canvas.id, tag=self.id, **draw_args)
Exemple #3
0
class DrawCircle(DrawCommand):
    """Draws a circle."""

    center: Tuple[float, float] = DrawPropertyPos2D()
    radius: float = DrawProperty()
    color: ColorRGBA = DrawPropertyColorRGBA()

    segments: int = DrawProperty()
    thickness: float = DrawProperty()
    fill: ColorRGBA = DrawPropertyColorRGBA()

    def __draw_internal__(self, draw_args) -> None:
        dpgcore.draw_circle(self.canvas.id, tag=self.id, **draw_args)
Exemple #4
0
class DrawRectangle(DrawCommand):
    """Draws a rectangle."""

    pmin: Tuple[float, float] = DrawPropertyPos2D()
    pmax: Tuple[float, float] = DrawPropertyPos2D()
    color: ColorRGBA = DrawPropertyColorRGBA()

    fill: ColorRGBA = DrawPropertyColorRGBA()
    rounding: float = DrawProperty()
    thickness: float = DrawProperty()

    def __draw_internal__(self, draw_args) -> None:
        dpgcore.draw_rectangle(self.canvas.id, tag=self.id, **draw_args)
Exemple #5
0
class DrawBezierCurve(DrawCommand):
    """Draws a bezier curve."""

    p1: Tuple[float, float] = DrawPropertyPos2D()
    p2: Tuple[float, float] = DrawPropertyPos2D()
    p3: Tuple[float, float] = DrawPropertyPos2D()
    p4: Tuple[float, float] = DrawPropertyPos2D()
    color: ColorRGBA = DrawPropertyColorRGBA()

    thickness: float = DrawProperty()
    segments: int = DrawProperty()

    def __draw_internal__(self, draw_args) -> None:
        dpgcore.draw_bezier_curve(self.canvas.id, tag=self.id, **draw_args)
Exemple #6
0
class DrawPolyLine(DrawCommand):
    """Draws connected lines."""
    @DrawProperty()
    def points(self) -> Sequence[Tuple[float, float]]:
        return [Pos2D(*p) for p in self.get_config()['points']]

    @points.getconfig
    def points(self, value: Sequence[Tuple[float, float]]):
        return {'points': [list(p) for p in value]}

    color: ColorRGBA = DrawPropertyColorRGBA()

    closed: bool = DrawProperty()
    thickness: float = DrawProperty()

    def __draw_internal__(self, draw_args) -> None:
        dpgcore.draw_polyline(self.canvas.id, tag=self.id, **draw_args)
Exemple #7
0
class DrawLine(DrawCommand):
    """Draws a line."""

    p1: Tuple[float, float] = DrawPropertyPos2D()
    p2: Tuple[float, float] = DrawPropertyPos2D()
    color: ColorRGBA = DrawPropertyColorRGBA()
    thickness: int = DrawProperty()

    def __draw_internal__(self, draw_args) -> None:
        dpgcore.draw_line(self.canvas.id, tag=self.id, **draw_args)
Exemple #8
0
class DrawTriangle(DrawCommand):
    """Draws a triangle."""

    p1: Pos2D = DrawPropertyPos()
    p2: Pos2D = DrawPropertyPos()
    p3: Pos2D = DrawPropertyPos()
    color: ColorRGBA = DrawPropertyColorRGBA()

    fill: ColorRGBA = DrawPropertyColorRGBA()
    thickness: float = DrawProperty()

    def _draw_internal(self, draw_args) -> None:
        dpgcore.draw_triangle(self.canvas.id, tag=self.id, **draw_args)
Exemple #9
0
class DrawQuad(DrawCommand):
    """Draws a quadrilateral."""

    p1: Tuple[float, float] = DrawPropertyPos2D()
    p2: Tuple[float, float] = DrawPropertyPos2D()
    p3: Tuple[float, float] = DrawPropertyPos2D()
    p4: Tuple[float, float] = DrawPropertyPos2D()
    color: ColorRGBA = DrawPropertyColorRGBA()

    fill: ColorRGBA = DrawPropertyColorRGBA()
    thickness: float = DrawProperty()

    def __draw_internal__(self, draw_args) -> None:
        dpgcore.draw_quad(self.canvas.id, tag=self.id, **draw_args)
Exemple #10
0
class DrawPolygon(DrawCommand):
    """Draws a polygon."""
    @DrawProperty()
    def points(self) -> Sequence[Pos2D]:
        return [DrawPos(*p) for p in self.get_config()['points']]

    @points.getconfig
    def points(self, value: Sequence[Pos2D]):
        return {'points': [list(p) for p in value]}

    color: ColorRGBA = DrawPropertyColorRGBA()

    fill: ColorRGBA = DrawPropertyColorRGBA()
    thickness: float = DrawProperty()

    def _draw_internal(self, draw_args) -> None:
        dpgcore.draw_polygon(self.canvas.id, tag=self.id, **draw_args)