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 float or an int, depending on the Vector queried.

Getter:

Gets the x-coordinate.

Setter:

Sets the x-coordinate.

property y : float | int

The y-coordinate of the vector. Returns either a float or an int, depending on the Vector queried.

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 a Vector is already passed in, in which case that instance is simply returned. Otherwise, a new Vector is constructed, populated, and returned.

Parameters:
point

The PrimitiveVector

type_cast

The internal type to store data as.

Returns:

A new Vector with the same position as point.

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.