TikZ¶
- Author
Marcel Simader
- Date
30.06.2021
New in version v0.1.0.
Point¶
- class Point(x, y, *, unit='', relative=False)¶
Point
represented a 2 dimensional coordinate of form \((x, y)\). The class additionally holds information on the unit used for both of the values. Various arithmetic operations upon two points are supported, but only if they share the same unit.To perform the vector dot product on two points, use the “matrix-mul” operator
@
.- Parameters
x (_N0) – the x-coordinate
y (_N1) – the y-coordinate
unit (AnyStr) – keyword-only argument, denotes the unit to suffix at the end of the
Point
instance, is automatically converted to all lower case, for instancePoint(3, 4, unit="CM")
will produce the output( 3.000cm, 4.000cm)
relative (bool) – whether or not this coordinate should be considered relative in the used path or not
- POINT_TEMPLATE: ClassVar[str] = '{}({: .7f}{unit}, {: .7f}{unit})'¶
The format string to use when formatting a coordinate to a string.
- property x: SEPTeX.TikZ._N0¶
- Returns
the x coordinate
- property y: SEPTeX.TikZ._N1¶
- Returns
the y coordinate
- property angle: float¶
- Returns
the angle of this coordinate in polar coordinates in degrees
- property radius: float¶
- Returns
the radius of this coordinate in polar coordinates
- property coordinate: Tuple[SEPTeX.TikZ._N0, SEPTeX.TikZ._N1]¶
- Returns
the tuple \((x, y)\)
- property polar_coordinate: Tuple[float, float]¶
- Returns
the tuple \((\theta, r)\)
- property point: SEPTeX.TikZ.Point[SEPTeX.TikZ._N0, SEPTeX.TikZ._N1]¶
- Returns
self
- property unit: AnyStr¶
- Returns
the all lower-case unit suffix
- property relative: bool¶
- Returns
whether or not this coordinate is relative
- as_int()¶
- Returns
a new coordinate \((\text{int}(x), \text{int}(y))\)
- Return type
SEPTeX.TikZ.Point[int, int]
- as_float()¶
- Returns
a new coordinate \((\text{float}(x), \text{float}(y))\)
- Return type
SEPTeX.TikZ.Point[float, float]
- geometric_length()¶
- Returns
the geometric length of this coordinate to the origin \(\vec 0\)
- Return type
float
- to_tikz()¶
Converts this object to a TikZ string.
PolarPoint¶
- class PolarPoint(angle, radius, *, unit='', relative=False)¶
PolarPoint
represents a coordinate in polar coordinates. It slightly modifies the functionality ofPoint
but has largely the same methods.- Parameters
angle (_N0) – the angle component in degrees
radius (_N1) – the radial component
unit (AnyStr) – keyword-only argument, denotes the unit to suffix at the end of the
Point
instance, is automatically converted to all lower case, for instancePolarPoint(314, 4, unit="CM")
will produce the output( 314.000: 4.000cm)
relative (bool) – whether or not this coordinate should be considered relative in the used path or not
- POINT_TEMPLATE: ClassVar[str] = '{}({: .7f}:{: .7f}{unit})'¶
The format string to use when formatting a coordinate to a string.
- property x: float¶
- Returns
the x coordinate
- property y: float¶
- Returns
the y coordinate
- property angle: SEPTeX.TikZ._N0¶
- Returns
the angle of this coordinate in polar coordinates in degrees
- property radius: SEPTeX.TikZ._N1¶
- Returns
the radius of this coordinate in polar coordinates
- as_int()¶
- Returns
a new coordinate \((\text{int}(\text{angle}), \text{int}(\text{radius}))\)
- Return type
SEPTeX.TikZ.PolarPoint[int, int]
- as_float()¶
- Returns
a new coordinate \((\text{float}(\text{angle}), \text{float}(\text{radius}))\)
- Return type
SEPTeX.TikZ.PolarPoint[float, float]
- to_tikz()¶
Converts this object to a TikZ string.
RelPoint¶
- class RelPoint(x, y, *, unit='')¶
RelPoint
is an alias ofPoint
with therelative
option set toTrue
by default.- Parameters
x (_N0) – the x-coordinate
y (_N1) – the y-coordinate
unit (AnyStr) – keyword-only argument, denotes the unit to suffix at the end of the
Point
instance, is automatically converted to all lower case, for instancePoint(3, 4, unit="CM")
will produce the output( 3.000cm, 4.000cm)
See also
Point
for more details.
TikZNode¶
- class TikZNode(coordinate=Point(x=0, y=0, relative=False), name='', label='', relative_to=None, style=TikZStyle(draw=True))¶
TikZNode
represents a standard TikZ node. It holds information about its coordinate, name, label and style. A node must first be registered with aTikZPicture
instance by writing it, which happens implicitly if not stated explicitly.- Parameters
coordinate (Point[_N0, _N1]) – the coordinate at which this node should be placed
name (AnyStr) – the name which will be used to reference this node
label (AnyStr) – the label which will be displayed on the document for this node
relative_to (Optional[TikZNode]) – the node to consider
coordinate
to be relative to, orNone
style (TikZStyle) – the style to apply to this node
- property raw_coordinate: SEPTeX.TikZ.Point[SEPTeX.TikZ._N0, SEPTeX.TikZ._N1]¶
- Returns
the raw coordinate of this node, this does not include the offset caused by a relative node
- property coordinate: SEPTeX.TikZ.Point¶
- Returns
the true coordinate of this node, with the offset caused by the relative node
- property label: str¶
- Returns
the label of this node
- property relative_to: Optional[SEPTeX.TikZ.TikZNode]¶
- Returns
the node which this node’s position is considered relative to, or
None
- property style: SEPTeX.TikZBase.TikZStyle¶
- Returns
the style used by this node
- property raw_name: str¶
- Returns
the name of this node without the parentheses
- property name: str¶
- Returns
the name of this node, including parentheses
- property definition: str¶
- Returns
the definition string of this object
TikZLabel¶
- class TikZLabel(label='', style=TikZStyle(draw=False))¶
TikZLabel
represents a TikZ label. These labels can be put onTikZNode
objects, or be used as labels for edges inTikZPath
objects.- Parameters
label (AnyStr) – the label text of this label
style (TikZStyle) – the style of this label,
draw
is set toFalse
by default
- property label: AnyStr¶
- Returns
the label text of this label
- property style: SEPTeX.TikZBase.TikZStyle¶
- Returns
the style of this label
- to_tikz()¶
Converts this object to a TikZ string.
TikZPath¶
- class TikZPath(coordinates, cycle=False, style=TikZStyle(draw=True))¶
TikZPath
represents a collection ofPoint
,TikZNode
, andTikZLabel
objects drawn using the\draw
command of TikZ.- Parameters
- static find_node_relations(coordinates, arrow_type)¶
Finds the relations between objects passed in through the
coordinates
argument. It essentially returns a tuple of tuples indicating whichTikZNode
objects “point” to which other nodes. For instance, if in a path noden0
points visually ton1
, then the output of this function will be((n0, n1),)
.- Parameters
coordinates (Sequence[Union[SEPTeX.TikZ.Point, SEPTeX.TikZ.TikZNode, SEPTeX.TikZ.TikZLabel]]) – a collection of
Point
,TikZNode
, orTikZLabel
objects for the patharrow_type (SEPTeX.TikZBase._TikZArrow) – the arrow type to consider when evaluating the node relations
- Returns
a tuple of tuples containing the relations between the nodes passed in through the
coordinates
argument- Return type
Tuple[Tuple[SEPTeX.TikZ.TikZNode, SEPTeX.TikZ.TikZNode], …]
- property arrow_type: Literal[TikZArrow(key='-')]¶
- Returns
the arrow type of a regular path is always
TikZArrow.LINE
- property coordinates_string: str¶
Converts all of the coordinates of this instance to a string. If there are no coordinates then the empty string is returned.
- property coordinates: Tuple[Union[SEPTeX.TikZ.Point, SEPTeX.TikZ.TikZNode, SEPTeX.TikZ.TikZLabel]]¶
- Returns
the points, nodes, and labels along this path
- property cycle: bool¶
- Returns
whether or not to join the end of this path to its beginning
- property style: SEPTeX.TikZBase.TikZStyle¶
- Returns
the style used by this path for its edge
- property node_relations: Tuple[Tuple[SEPTeX.TikZ.TikZNode, SEPTeX.TikZ.TikZNode], ...]¶
- Returns
the node relations of this path, as described by
find_node_relations()
- to_tikz()¶
Converts this object to a TikZ string.
TikZDirectedPath¶
- class TikZDirectedPath(coordinates, cycle=False, style=TikZStyle(draw=True), arrow_type=TikZArrow(key='-'))¶
TikZDirectedPath
represents a path similarly toTikZPath
but with additional information on the arrow type used to join up the coordinates.This class implicitly uses the
arrows
TikZ library.- Parameters
coordinates (Sequence[Union[Point, TikZNode, TikZLabel]]) – a collection of
Point
orTikZNode
objects for the pathcycle (bool) – whether or not to end the final path string with
cycle
, which will join the ending to the beginningstyle (TikZStyle) – the style to apply to this path
arrow_type (_TikZArrow) – the
_TikZArrow
to use for the arrow tip of the edge
- property arrow_type: SEPTeX.TikZBase._TikZArrow¶
- Returns
which arrow head type is used by this path
- to_tikz()¶
Converts this object to a TikZ string.
TikZCircle¶
- class TikZCircle(coordinate, radius, style=TikZStyle(draw=True))¶
TikZCircle
represents a standard TikZ circle, with a center coordinate, radius and style.- Parameters
- property coordinate: SEPTeX.TikZ.Point[SEPTeX.TikZ._N0, SEPTeX.TikZ._N1]¶
- Returns
the center coordinate of this circle
- property radius: TikZValue¶
- Returns
the radius of this circle
- property style: SEPTeX.TikZBase.TikZStyle¶
- Returns
the style used by this circle
- to_tikz()¶
Converts this object to a TikZ string.