跳转至

maliang.standard.shapes

字数 9 个   阅读时间不到 1 分钟   访问量

源代码:maliang/standard/shapes.py

All standard Shape classes

类:

Line

Line(
    widget: virtual.Widget,
    relative_position: tuple[int, int] = (0, 0),
    size: tuple[int, int] | None = None,
    *,
    points: list[tuple[float, float]] | None = None,
    name: str | None = None,
    gradient_animation: bool = True,
    **kwargs
)

Bases: virtual.Shape

Create a line for a widget

  • widget: parent widget
  • relative_position: position relative to its widgets
  • size: size of element
  • points: key points of line
  • name: name of element
  • gradient_animation: Wether use animation to change color
  • kwargs: extra parameters for CanvasItem

方法:

  • display

    Display the Element on a Canvas

  • coords

    Resize the Element

display

display() -> None

Display the Element on a Canvas

coords

coords(
    size: tuple[float, float] | None = None, position: tuple[float, float] | None = None
) -> None

Resize the Element

Rectangle

Rectangle(
    widget: Widget,
    position: tuple[int, int] = (0, 0),
    size: tuple[int, int] | None = None,
    *,
    name: str | None = None,
    gradient_animation: bool | None = None,
    **kwargs
)

Bases: virtual.Shape

Create a rectangle for a widget

方法:

  • display

    Display the Element on a Canvas

  • coords

    Resize the Element

display

display() -> None

Display the Element on a Canvas

coords

coords(
    size: tuple[float, float] | None = None, position: tuple[float, float] | None = None
) -> None

Resize the Element

Oval

Oval(
    widget: Widget,
    position: tuple[int, int] = (0, 0),
    size: tuple[int, int] | None = None,
    *,
    name: str | None = None,
    gradient_animation: bool | None = None,
    **kwargs
)

Bases: virtual.Shape

Create a oval for a widget

方法:

  • display

    Display the Element on a Canvas

  • coords

    Resize the Element

  • detect

    Detect whether the specified coordinates are within Element

display

display() -> None

Display the Element on a Canvas

coords

coords(
    size: tuple[float, float] | None = None, position: tuple[float, float] | None = None
) -> None

Resize the Element

detect

detect(x: int, y: int) -> bool

Detect whether the specified coordinates are within Element

Arc

Arc(
    widget: Widget,
    position: tuple[int, int] = (0, 0),
    size: tuple[int, int] | None = None,
    *,
    name: str | None = None,
    gradient_animation: bool | None = None,
    **kwargs
)

Bases: virtual.Shape

Create a arc for a widget

方法:

  • display

    Display the Element on a Canvas

  • coords

    Resize the Element

display

display() -> None

Display the Element on a Canvas

coords

coords(
    size: tuple[float, float] | None = None, position: tuple[float, float] | None = None
) -> None

Resize the Element

RegularPolygon

RegularPolygon(
    widget: virtual.Widget,
    relative_position: tuple[int, int] = (0, 0),
    size: tuple[int, int] | None = None,
    *,
    side: int = 3,
    angle: float = 0,
    name: str | None = None,
    gradient_animation: bool = True,
    **kwargs
)

Bases: virtual.Shape

Create a regular polygon for a widget

  • widget: parent widget
  • relative_position: position relative to its widgets
  • size: size of element
  • side: number of sides of a regular polygon
  • angle: number of radians of a regular polygon rotated clockwise
  • name: name of element
  • gradient_animation: Wether use animation to change color
  • kwargs: extra parameters for CanvasItem

方法:

  • display

    Display the Element on a Canvas

  • coords

    Resize the Element

display

display() -> None

Display the Element on a Canvas

coords

coords(
    size: tuple[float, float] | None = None, position: tuple[float, float] | None = None
) -> None

Resize the Element

RoundedRectangle

RoundedRectangle(
    widget: virtual.Widget,
    relative_position: tuple[int, int] = (0, 0),
    size: tuple[int, int] | None = None,
    *,
    radius: int = 5,
    name: str | None = None,
    gradient_animation: bool = True,
    **kwargs
)

Bases: virtual.Shape

Create a rounded rectangle for a widget

  • widget: parent widget
  • relative_position: position relative to its widgets
  • size: size of element
  • radius: radius of the fillet
  • name: name of element
  • gradient_animation: Wether use animation to change color
  • kwargs: extra parameters for CanvasItem

方法:

  • display

    Display the Element on a Canvas

  • coords

    Resize the Element

display

display() -> None

Display the Element on a Canvas

coords

coords(
    size: tuple[float, float] | None = None, position: tuple[float, float] | None = None
) -> None

Resize the Element

HalfRoundedRectangle

HalfRoundedRectangle(
    widget: virtual.Widget,
    relative_position: tuple[int, int] = (0, 0),
    size: tuple[int, int] | None = None,
    *,
    radius: int = 5,
    ignore: typing.Literal["left", "right"] = "left",
    name: str | None = None,
    gradient_animation: bool = True,
    **kwargs
)

Bases: virtual.Shape

Create a half rounded rectangle for a widget

  • widget: parent widget
  • relative_position: position relative to its widgets
  • size: size of element
  • radius: radius of the fillet
  • ignore: edges to ignore
  • name: name of element
  • gradient_animation: Wether use animation to change color
  • kwargs: extra parameters for CanvasItem

方法:

  • display

    Display the Element on a Canvas

  • coords

    Resize the Element

display

display() -> None

Display the Element on a Canvas

coords

coords(
    size: tuple[float, float] | None = None, position: tuple[float, float] | None = None
) -> None

Resize the Element

SemicircularRectangle

SemicircularRectangle(
    widget: Widget,
    position: tuple[int, int] = (0, 0),
    size: tuple[int, int] | None = None,
    *,
    name: str | None = None,
    gradient_animation: bool | None = None,
    **kwargs
)

Bases: virtual.Shape

Create a semicircular rectangle for a widget

方法:

  • display

    Display the Element on a Canvas

  • coords

    Resize the Element

  • detect

    Detect whether the specified coordinates are within Element

display

display() -> None

Display the Element on a Canvas

coords

coords(
    size: tuple[float, float] | None = None, position: tuple[float, float] | None = None
) -> None

Resize the Element

detect

detect(x: int, y: int) -> bool

Detect whether the specified coordinates are within Element

SharpRectangle

SharpRectangle(
    widget: virtual.Widget,
    relative_position: tuple[int, int] = (0, 0),
    size: tuple[int, int] | None = None,
    *,
    theta: float = math.pi / 6,
    ratio: tuple[float, float] = (0.5, 0.5),
    name: str | None = None,
    gradient_animation: bool = True,
    **kwargs
)

Bases: virtual.Shape

Create a sharp rectangle for a widget

  • widget: parent widget
  • relative_position: position relative to its widgets
  • size: size of element
  • theta: number of radians of sharp corners
  • ratio: height ratio of the left and right sharp corners
  • name: name of element
  • gradient_animation: Wether use animation to change color
  • kwargs: extra parameters for CanvasItem

方法:

  • display

    Display the Element on a Canvas

  • coords

    Resize the Element

display

display() -> None

Display the Element on a Canvas

coords

coords(
    size: tuple[float, float] | None = None, position: tuple[float, float] | None = None
) -> None

Resize the Element

Parallelogram

Parallelogram(
    widget: virtual.Widget,
    relative_position: tuple[int, int] = (0, 0),
    size: tuple[int, int] | None = None,
    *,
    theta: float = math.pi / 6,
    name: str | None = None,
    gradient_animation: bool = True,
    **kwargs
)

Bases: virtual.Shape

Create a parallelogram for a widget

  • widget: parent widget
  • relative_position: position relative to its widgets
  • size: size of element
  • theta: number of radians that the parallelogram is inclined to
  • name: name of element
  • gradient_animation: Wether use animation to change color
  • kwargs: extra parameters for CanvasItem

方法:

  • display

    Display the Element on a Canvas

  • coords

    Resize the Element

display

display() -> None

Display the Element on a Canvas

coords

coords(
    size: tuple[float, float] | None = None, position: tuple[float, float] | None = None
) -> None

Resize the Element