tikzfigure.core.rectangle
Classes
| Name | Description |
|---|---|
Rectangle | A TikZ rectangle drawn with \draw rectangle or \filldraw rectangle. |
Rectangleclass#
class Rectangle(corner1: PositionInput, corner2: PositionInput, label: str = '', comment: str | None = None, layer: int = 0, options: OptionInput | None = None, tikz_command: str = 'draw', **kwargs: Any)Bases: TikzObject
A TikZ rectangle drawn with \draw rectangle or \filldraw rectangle.
Attributes
| Name | Type | Description |
|---|---|---|
corner1 | TikzCoordinate | First corner coordinate. |
corner2 | TikzCoordinate | Second corner coordinate (opposite corner). |
tikz_command | str | The TikZ drawing command (“draw” or “filldraw”). |
corner1property#
corner1: TikzCoordinateFirst corner coordinate of the rectangle.
corner2property#
corner2: TikzCoordinateSecond (opposite) corner coordinate of the rectangle.
tikz_commandproperty#
tikz_command: strThe TikZ drawing command (“draw” or “filldraw”).
from_dictmethodclassmethod#
def from_dict(d: dict[str, Any]) -> RectangleReconstruct a Rectangle from a dictionary.
Returns
Rectangle- A new Rectangle instance.
to_dictmethod#
def to_dict() -> dict[str, Any]Serialize this rectangle to a plain dictionary.
to_tikzmethod#
def to_tikz(output_unit: str | None = None) -> strGenerate the TikZ rectangle command for this rectangle.
Inherited from tikzfigure.core.base.TikzObject
commentproperty#
tikzfigure.core.base.TikzObjectView sourcecomment: str | NoneComment prepended to the generated TikZ code, or None.
kwargsproperty#
tikzfigure.core.base.TikzObjectView sourcekwargs: dictKeyword-style TikZ options as a plain dict.
labelproperty#
tikzfigure.core.base.TikzObjectView sourcelabel: str | NoneUnique identifier for this object within the figure.
layerproperty#
tikzfigure.core.base.TikzObjectView sourcelayer: int | NoneLayer index this object belongs to.
optionsproperty#
tikzfigure.core.base.TikzObjectView sourceoptions: list[OptionValue]Flag-style TikZ options without values.
add_commentmethod#
tikzfigure.core.base.TikzObjectView sourcedef add_comment(string_in: str) -> strPrepend a TikZ comment line to a string if a comment is set.
Parameters
| Name | Type | Description |
|---|---|---|
string_in | str | The TikZ code string to annotate. |
copymethod#
tikzfigure.core.base.TikzObjectView sourcedef copy(**overrides: Any) -> TikzObjectReturn a copy of this object with optional constructor-style overrides.
tikz_optionsmethod#
tikzfigure.core.base.TikzObjectView sourcedef tikz_options(output_unit: str | None = None) -> strRender all options as a single TikZ option string.
Combines flag-style options and keyword options into the format
expected inside TikZ square brackets, e.g.
"thick, color=red, line width=1pt".
Parameters
Returns
str- A comma-separated string of TikZ options.
