Rectangle

class img_gen.Rectangle(color: ColorKind, radius: float = 0, corners: list[Corners] | None = None, border: Border | None = None)

An attribute to represent a rectangle rendered in the layer.

The size of the rectangle is specified by the layer’s size.

as_json_str()

Serialize the Rectangle object to a JSON string.

as_yaml_str()

Serialize the Rectangle object to a YAML string.

border

The [Border] (if specified) to render around the rectangle.

color

The color used to fill the rectangle.

corners

A list of the [Corners] in which the radius is applied.

Any [Corners] not in this list will not be rounded.

static from_json_str(json_str)

Deserialize a Rectangle object from a JSON string.

static from_yaml_str(yaml_str)

Deserialize a Rectangle object from a YAML string.

radius

The radius of the rendered [Rectangle::corners].

The renderer shall limit this value if it is greater than half the minimum of the rectangle’s width or height (see [Layer::size](value@crate::Layer::size)).

class img_gen.Corners

An enum to represent the possible options in specifying which [Rectangle::corners] to render rounded.

TopLeft = Corners.TopLeft
TopRight = Corners.TopRight
BottomLeft = Corners.BottomLeft
BottomRight = Corners.BottomRight
static all()

Returns a list of all corner enum values.

as_json_str()

Serialize the Corners object to a JSON string.

as_yaml_str()

Serialize the Corners object to a YAML string.

static from_json_str(json_str)

Deserialize a Corners object from a JSON string.

static from_yaml_str(yaml_str)

Deserialize a Corners object from a YAML string.