vector¶
- class Vector(x: float | int, y: float | int)¶
A simple 2d vector class, used to aid in developent and user experience.
- property x : float | int¶
The x-coordinate of the point. Returns either a
floator anint, depending on theVectorqueried.- Getter:
Gets the x-coordinate.
- Setter:
Sets the x-coordinate.
- property y : float | int¶
The y-coordinate of the vector. Returns either a
floator anint, depending on theVectorqueried.- Getter:
Gets the y-coordinate.
- Setter:
Sets the y-coordinate.
- classmethod from_other(other: ~draftsman.classes.vector.Vector | tuple[int | float, int | float], type_cast: ~typing.Callable = <class 'float'>) Vector¶
Converts a PrimitiveVector into a
Vector. Also handles the case where aVectoris already passed in, in which case that instance is simply returned. Otherwise, a newVectoris constructed, populated, and returned.- Parameters:
- point
The PrimitiveVector
- type_cast
The internal type to store data as.
- Returns:
A new
Vectorwith the same position aspoint.
- to_dict() dict¶
Convert this vector to a Factorio-parseable dict with “x” and “y” keys.
- Returns:
A dict of the format
{"x": x, "y": y}.
- update(x: float | int, y: float | int) None¶
Updates the data of the existing vector in-place. Useful for preserving linked vectors.
- update_from_other(other: ~draftsman.classes.vector.Vector | tuple[int | float, int | float], type_cast: ~typing.Callable = <class 'float'>) None¶
Updates the data of the existing vector in-place from a variable input format.
- Parameters:
- other
The object to get the new set of data from
- type_cast
The data type to coerce the input variables towards.