RAIMAD

raimad.BoundPoint

class BoundPoint( builtins.object, ):
A point bound to a Proxy. There is often a desire to perform a certain transformation of some proxy in reference to a given point at that proxy. We might want to rotate a proxy around the top left corner of its bbox, or move a proxy such that one of its marks is at a given point. These things can be done with the following syntax in raimad: - `someproxy.bbox.top_left.rotate(someangle)` - `someproxy.marks.important_mark.to((x, y))` In the examples above, `top_left` and `important_mark` are both BoundPoints. They behave just like regular points (a tuple of x and y), but they also define transformation methods like `rotate`, `to`, `vflip`, and so forth that perform the corresponding transformation to the bound proxy, with the BoundPoint treated as the new origin for the transformation.

def __init__(self, x: float | int | SupportsFloat, y: float | int | SupportsFloat, proxy: 'rai.typing.Proxy'):

Initialize new boundpoint.
Note that in normal RAIMAD usage, you should not have to create boundpoints manually.
Parameters
x
The x coordinate of the point
y
The y coordinate of the point
proxy
The proxy this to bind to

def __getitem__(self, index: Literal[0, 1]) -> float | int | SupportsFloat:

Get the X or Y coordinate of this BoundPoint.
Parameters
index: int
0 or 1 for the x and y coordinate respectively
Returns
Num
The coordinate value
Raises
IndexError
IndexError is raised if `index` is anything other than 0 or 1.

def __iter__(self) -> Iterator[float | int | SupportsFloat]:

Return an iterator of the x and y coordinates of this BoundPoint.
Returns
Iterator[Num]
Iterator containing x and y coordinate.

def __eq__(self, other: object) -> bool:

Check for equality of BoundPoint.
Comparing BoundPoints using the == operator (i.e. this method) may be a bad idea for the same reason that comparing floats in this way is a bad idea.
Parameters
other: object
The object to check equality against. This may be another BoundPoint, a regular Point, or any other object. If `other` does not implement a `__getitem__` method, then the result is automatically zero. If `other` does implement `__getitem__`, then the result is True iff the x coordinate of this boundpoint == other[0] and the y coordinate of this boundpoint == other[1].
Returns
bool
True if this boundpoint is equal to `other`, False otherwise.

def __repr__(self) -> str:

Return string representation of this BoundPoint.
Returns
str
TODO sample string

def __str__(self) -> str:

Return string representation of this BoundPoint.
Returns
str
TODO sample string

def rotate(self, angle: float | int | SupportsFloat) -> 'rai.typing.Proxy':

Rotate the bound Proxy around this BoundPoint.
Parameters
angle: Num
The rotation angle, specified in radians in the positive direction.
Returns
rai.typing.Proxy
The bound proxy (not this BoundPoint!) is returned to allow chaining methods.

def cmove(self, x: float | int | SupportsFloat = 0, y: float | int | SupportsFloat = 0) -> 'rai.typing.Proxy':

Translate by x and y.
Parameters
xNum
Move this many units along x axis.
yNum
Move this many units along y axis.
Returns
rai.typing.Proxy
The bound proxy (not this BoundPoint!) is returned to allow chaining methods.

def pmove(self, offset: raimad.types.Vec2) -> 'rai.typing.Proxy':

Translate by x and y, given as a tuple.
Parameters
offsetVec2
A tuple of two values (x, y).
Returns
rai.typing.Proxy
The bound proxy (not this BoundPoint!) is returned to allow chaining methods.

def move(self, /, a: float | int | SupportsFloat | raimad.types.Vec2, b: float | int | SupportsFloat | None = None) -> 'rai.typing.Proxy':

Translate vertically and horizontally (overload).
This is an overloaded method that can take the X and Y offsets either as two separate x and y arguments, or as a single tuple of two values.
Parameters
aNum | Vec2
X offset or tuple of offsets
bNum | None
Y offset or None
Returns
rai.typing.Proxy
The bound proxy (not this BoundPoint!) is returned to allow chaining methods.

def movex(self, x: float | int | SupportsFloat = 0) -> 'rai.typing.Proxy':

Move along x axis.
Parameters
xNum
Move this many units along x axis.
Returns
rai.typing.Proxy
The bound proxy (not this BoundPoint!) is returned to allow chaining methods.

def movey(self, y: float | int | SupportsFloat = 0) -> 'rai.typing.Proxy':

Move along y axis.
Parameters
yNum
Move this many units along y axis.
Returns
rai.typing.Proxy
The bound proxy (not this BoundPoint!) is returned to allow chaining methods.

def flip(self) -> 'rai.typing.Proxy':

Flip the bound proxy around this boundpoint.
Returns
rai.typing.Proxy
The bound proxy (not this BoundPoint!) is returned to allow chaining methods.

def hflip(self) -> 'rai.typing.Proxy':

Flip proxy along horizontal axis passing thru this boundpoint.
Returns
rai.typing.Proxy
The bound proxy (not this BoundPoint!) is returned to allow chaining methods.

def vflip(self) -> 'rai.typing.Proxy':

Flip the bound proxy along vertical axis passing thru this boundpoint.
Returns
rai.typing.Proxy
The bound proxy (not this BoundPoint!) is returned to allow chaining methods.

def cscale(self, x: float | int | SupportsFloat, y: float | int | SupportsFloat) -> 'rai.typing.Proxy':

Scale width and height (two floats) with this boundpoint as pivot.
Parameters
xNum
Factor to scale by along the x axis
yNum
Factor to scale by along the y axis.
Returns
rai.typing.Proxy
The bound proxy (not this BoundPoint!) is returned to allow chaining methods.

def pscale(self, scale: raimad.types.Vec2) -> 'rai.typing.Proxy':

Scale width and height (tuple) with this boundpoint as pivot.
Parameters
scaleVec2
The x and y scale factors
Returns
rai.typing.Proxy
The bound proxy (not this BoundPoint!) is returned to allow chaining methods.

def ascale(self, factor: float | int | SupportsFloat) -> 'rai.typing.Proxy':

Scale width and height by same factor with this boundpoint as pivot.
Parameters
factorNum
Factor to scale by.
Returns
rai.typing.Proxy
The bound proxy (not this BoundPoint!) is returned to allow chaining methods.

def scale(self, /, a: float | int | SupportsFloat | raimad.types.Vec2, b: float | int | SupportsFloat | raimad.types.Vec2 | None = None) -> 'rai.typing.Proxy':

Scale width and height, using self as pivot point (overload).
This is an overloaded function. It can take: - single scale factor - `self.scale(5)` - x, y scale factors (separate values) - `self.scale(5, 4)` - x, y scale factors (tuple) - `self.scale((5, 4))`
Returns
rai.typing.Proxy
The bound proxy (not this BoundPoint!) is returned to allow chaining methods.

def pto(self, point: raimad.types.Vec2) -> 'rai.typing.Proxy':

Move the Proxy such that this BoundPoint ends up at `point` (tuple).
Parameters
point: Vec2
Target point.
Returns
rai.typing.Proxy
The bound proxy (not this BoundPoint!) is returned to allow chaining methods.

def cto(self, x: float | int | SupportsFloat, y: float | int | SupportsFloat) -> 'rai.typing.Proxy':

Move the Proxy so that this BoundPoint ends up at `point` (two Nums).
Parameters
xNum
Move this many units along x axis.
yNum
Move this many units along y axis.
Returns
rai.typing.Proxy
The bound proxy (not this BoundPoint!) is returned to allow chaining methods.

def to(self, a: float | int | SupportsFloat | raimad.types.Vec2, b: float | int | SupportsFloat | None = None) -> 'rai.typing.Proxy':

Move the Proxy so that this BoundPoint ends up at `point` (overload).
This is an overloaded method that can take the position of the target point either as two separate x and y arguments, or as a single tuple of two values.
Parameters
aNum | Vec2
Either the X coordinate or target point
bNum | None
Either the Y coordinate or None
Returns
rai.typing.Proxy
The bound proxy (not this BoundPoint!) is returned to allow chaining methods.

def __annotate_func__(format, /):