Point
Point
A class to handle points for TikzPy.
The Point class is how TikzPy handles coordinates. All drawing objects, like Line and Circle, use the Point class under the hood.
The Point class is designed to perform arithmetic with instances of itself and with Python tuples. The constructor accepts can either accept two numeric arguments, a single tuple of floats argument, or a single Point object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
first_arg |
Union[float, Number, tuple, Point]
|
A number, a tuple, or Point object. |
required |
second_arg |
Union[float, Number, None]
|
A number, in the case of a 2D point, or None. |
None
|
third_arg |
Union[float, Number, None]
|
A number, in the case of a 3D point, or None. |
None
|
rotate
rotate(
angle: float,
about_pt: Union[Tuple[float, float], Point],
radians: bool = False,
) -> Point
Returns a point that is rotated about another point.
rotate_
rotate_(
angle: float,
about_pt: Union[Tuple[float, float], Point],
radians: bool = False,
) -> None
Rotate the point about another point. This performs an in-place operation.
scale_
Scale the point given the scale. This performs an in-place operation.
shift
Returns a point translated by x, y, z offsets.
shift_
Translate the point via x, y offsets. This performs an in-place operation.
Examples
The Point
class can be instantiated from a tuple or at least two Number
s. One can also represent a point in 3D with this class.
Point
objects, either with other Point
objects or with Python tuples. For example, the following are all valid.
>>> my_point + (1, 1) # Add it to another tuple
Point(0, 3)
>>> my_point + Point(2, 2) # Add it with another point object
Point(1, 4)
>>> 2 * my_point # Can also do my_point * 2
Point(-2, 4)
>>> my_point / 3
Point(-0.33333333, 0.666666666)
This allows you to write things like
and this feature becomes quite useful in drawings that are highly complex.