Common¶
- class mh_en_exec.nodes.common.Size(width=0, height=0)¶
The Size class defines the size of a two-dimensional object using floating point precision.
- Parameters
width (float, optional) – width
height (float, optional) – height
- class mh_en_exec.nodes.common.Point(x=0, y=0)¶
The Point class defines the point in two-dimensional space using floating point precision.
- Parameters
x (float, optional) – coordinate on the x-axis
y (float, optional) – coordinate on the y-axis
- class mh_en_exec.nodes.common.PointWithUnit(x=0, y=0, unit='px')¶
The PointWithUnit class defines the point in two-dimensional space with particular unit using floating point precision.
- Parameters
x (float, optional) – coordinate on the x-axis
y (float, optional) – coordinate on the y-axis
unit (str, optional) – coordinate unit
Note
Coordinate Unit:‘px’ - value in pixels‘hu’ - value in height units.Ex. 1hu is {height of the screen} / 100‘%’ - value in percentages.Ex. 50% of the x is half of the width of the screen- classmethod lerp(start, end, t)¶
Linearly interpolates between two points
- Parameters
start (PointWithUnit) – Start point
end (PointWithUnit) – End point
t (float) – value used to interpolate between start and end. Range between 0.0 and 1.0
- class mh_en_exec.nodes.common.Rect(left=0, top=0, right=0, bottom=0)¶
The Rect class defines the rectangle shape in two-dimensional space using floating point precision.
- Parameters
left (float, optional) – leftmost coordinate on the x-axis
top (float, optional) – topmost coordinate on the y-axis
right (float, optional) – rightmost coordinate on the x-axis
bottom (float, optional) – bottommost coordinate on the y-axis
- isInside(point)¶
Checks if the point is inside the rectangle
- Parameters
point (Point) – point
- Returns
True if inside and False if outside
- Return type
bool
- isValid()¶
Checks if the rectangle is valid
- Returns
True if valid and False if invalid
- Return type
bool
- class mh_en_exec.nodes.common.RectWithUnit(left=0, top=0, right=0, bottom=0, unit='px')¶
The RectWithUnit class defines the rectangle shape in two-dimensional space with particular unit using floating point precision.
- Parameters
left (float, optional) – leftmost coordinate on the x-axis
top (float, optional) – topmost coordinate on the y-axis
right (float, optional) – rightmost coordinate on the x-axis
bottom (float, optional) – bottommost coordinate on the y-axis
unit (str, optional) – coordinate unit
Note
Coordinate Unit:‘px’ - value in pixels‘hu’ - value in height units.Ex. 1hu is {height of the screen} / 100‘%’ - value in percentages.Ex. 50% of the x is half of the width of the screen- center()¶
Returns rectangle’s center point
- Returns
rectangle center
- Return type
- getAxisSwapped()¶
Returns axis swapped rectangle
- Returns
axis swapped rectangle
- Return type
- isInside(point)¶
Checks if the point is inside the rectangle
- Parameters
point (PointWithUnit) – point
- Raises
ValueError – In case of unit value of the point is not the same as unit of the rectangle
- Returns
True if inside and False if outside
- Return type
bool
- isValid()¶
Checks if the rectangle is valid
- Returns
True if valid and False if invalid
- Return type
bool
- toPx(size)¶
Returns RectWithUnit in pixel units
- Parameters
size (Size) – Screen size
- Raises
ValueError – In case of unknown unit value
- Returns
rectangle in pixel units
- Return type
- transform(delta, relSize=None)¶
Transforms rectangle to delta
- Parameters
delta (RectWithUnit) – delta rectangle
relSize (Size) – Screen size
- Raises
ValueError – In case of delta is not instance of RectWithUnit or relSize is not set in case of this rectangle is not in pixel unit
- Returns
transformed rectangle
- Return type
- class mh_en_exec.nodes.common.Vector(x=0.0, y=0.0)¶
The Vector class defines the vector in two-dimensional space using floating point precision.
- Parameters
x (float, optional) – coordinate on the x-axis
y (float, optional) – coordinate on the y-axis
- classmethod fromPoint(point: mh_en_exec.nodes.common.Point) mh_en_exec.nodes.common.Vector ¶
Returns Vector converted from point
- Raises
ValueError – If the point does not exist
- Parameters
point (Point) – Point in two-dimensional space
- classmethod fromPoints(origin: mh_en_exec.nodes.common.Point, point: mh_en_exec.nodes.common.Point) mh_en_exec.nodes.common.Vector ¶
Returns Vector calculated from two points
- property magnitude¶
Returns the length of this vector
- Returns
length of this vector
- Return type
float
- normalize()¶
Makes this vector have a magnitude of 1.0
- class mh_en_exec.nodes.common.VectorWithUnit(x=0.0, y=0.0, unit='px', **kwargs)¶
The VectorWithUnit class defines the vector in two-dimensional space with particular unit using floating point precision.
- Parameters
x (float, optional) – coordinate on the x-axis
y (float, optional) – coordinate on the y-axis
unit (str, optional) – coordinate unit
Note
Coordinate Unit:‘px’ - value in pixels‘hu’ - value in height units.Ex. 1hu is {height of the screen} / 100‘%’ - value in percentages.Ex. 50% of the x is half of the width of the screen- classmethod fromPoint(point: mh_en_exec.nodes.common.PointWithUnit) mh_en_exec.nodes.common.VectorWithUnit ¶
Returns VectorWithUnit converted from point
- Raises
ValueError – If the point does not exist
- Parameters
point (PointWithUnit) – Point in two-dimensional space
- classmethod fromPoints(origin: mh_en_exec.nodes.common.PointWithUnit, point: mh_en_exec.nodes.common.PointWithUnit) mh_en_exec.nodes.common.VectorWithUnit ¶
Returns VectorWithUnit calculated from two points
- Raises
ValueError – If starting point or terminal point does not exist, also if unit of two points is not same
- Parameters
origin (PointWithUnit) – Starting point in two-dimensional space
point (PointWithUnit) – Terminal point in two-dimensional space
- property magnitude¶
Returns the length of this vector
- Returns
length of this vector
- Return type
float
- normalize()¶
Makes this vector have a magnitude of 1.0