RAIMAD

raimad.Proxy

class Proxy( builtins.object, ):
Proxy: transforming and layermapping wrapper around a Compo. TODO description here.

def __init__(self, compo: 'rai.typing.CompoLike', lmap: 'rai.typing.LMapShorthand' = None, transform: 'rai.typing.Transform | None' = None, _cif_link: bool = False, _autogenned: bool = False, _deepcopied: bool = False):

Create new Proxy.
Do not instantiate Proxies directly unless you have a good reason to. Use `Compo.proxy()` instead.
Parameters
compo
The compo or proxy that the new proxy will point to
lmap
Layer map shorthand for the new proxy
transform:
Transformation for the new proxy (None for identity transform)

def steamroll(self) -> 'rai.typing.Geoms':

Get all geometries of this proxy.
Returns
rai.typing.Geoms
Returns all geometries (i.e. all raw geometries as well as subcompos) of the CompoLike pointed to by this proxy, as seen through this proxy.
TODO example

def get_flat_transform(self, maxdepth: int = -1) -> 'rai.typing.Transform':

Get flattened transform from tower of proxies.
Parameters
maxdepth
Stop at this many proxies. -1 means no limit.
Returns
rai.typing.Transform
A new transform that is eqiuivalent to applying all transform in this proxy tower.

def get_flat_lmap(self, maxdepth: int = -1) -> raimad.proxy.LMap:

Get flattened layermap from tower of proxies.
Parameters
maxdepth
Stop at this many proxies. -1 means no limit.
Returns
LMap
A new layermap that is eqiuivalent to applying all layermaps in this proxy tower successibely.

def final(self) -> 'rai.typing.Compo':

Return the compo at the bottom of a tower of proxies.
Returns
rai.typing.Compo
The compo at the bottom of a tower of proxies

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

Return the proxy at the bottom of a tower of proxies.
Returns
rai.typing.Compo
The proxy at the bottom of a tower of proxies -- i.e. the second-to-last element in the tower of proxies.

def depth(self) -> int:

Measure depth of a tower of proxies.
Returns
int
0 if called on a compo, 1 if called on a proxy of a compo, 2 if called on a proxy of a proxy of a compo, and so on.

def descend(self) -> 'Iterator[rai.typing.CompoLike]':

Descend a tower of proxies to the compo at the bottom.
s e l f y i e l d p r o x y y i e l d p r o x y y i e l d c o m p o y i e l d
Yields
rai.typing.CompoLike
Yields all of the proxies in the tower, and the compo at the very bottom.

def descend_p(self) -> 'Iterator[rai.typing.Proxy]':

Descend a tower of proxies to the lowest proxy.
s e l f y i e l d p r o x y y i e l d p r o x y y i e l d c o m p o d o n t y i e l d
Yields
rai.typing.Proxy
Yields all of the proxies in the tower, but no the compo at the bottom.

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

Return a new proxy pointing to this proxy.
Returns
rai.typing.Proxy
The new proxy

def walk_hier(self) -> 'Iterator[rai.typing.Proxy]':

Traverse the subcomponent hierarchy of the CompoLike of this proxy.
This method will recursively walk through the entire subcompo hierarchy of the CompoLike pointed to by this proxy. Each node is wrapped in a copy of this proxy. TODO explain better
Yields
rai.typing.Proxy
For every subcomponent in the hierarchy, a copy of this proxy tower (i.e. self.deep_copy_reassign) is returned that points to the subcomponent.

def shallow_copy(self, _autogenned: bool = False, _deepcopied: bool = False) -> 'rai.typing.Proxy':

Make a shallow copy of this proxy.
This function returns a new proxy that is a copy of this proxy. If this proxy points to a different proxy, the target proxy is NOT coppied. In other words, if the current proxy is a proxy tower, only the topmost proxy is copied.
s e l f c o p y t h i s i s r e t u r n e d p r o x y p r o x y c o m p o
Returns
rai.typing.Proxy
Copy of this proxy

def shallow_copy_reassign(self, new_compo: 'rai.typing.CompoLike', _autogenned: bool = False, _deepcopied: bool = False) -> 'rai.typing.Proxy':

Make a shallow copy of this proxy and reassign to a new CompoLike.
This function returns a new proxy that is a copy of this proxy, but reassigned to `new_compo`. if the current proxy is a proxy tower, the proxies below this one are esentially ignored. The returned proxy is always pointing directly to `new_compo`, and the layermap and transform is exactly the same as this proxy.
s e l f c o p y t h i s i s r e t u r n e d p r o x y p r o x y c o m p o n e w _ c o m p o
Returns
rai.typing.Proxy
Copy of this proxy reassigned to `new_compo`

def deep_copy(self, _autogenned: bool = False) -> 'rai.typing.Proxy':

Make a deep copy of this proxy.
If this proxy is pointing directly to a compo, then this method is identical to `self.shallow_copy`. If, however, this proxy is a proxy tower, then all of the proxies in the tower are copied.
s e l f c o p y t h i s i s r e t u r n e d p r o x y c o p y p r o x y c o p y c o m p o
Returns
rai.typing.Proxy
Deep copy of this proxy

def deep_copy_reassign(self, new_compo: 'rai.typing.CompoLike', _autogenned: bool = False, _deepcopied: bool = False) -> 'rai.typing.Proxy':

Make a deep copy of this proxy and reassign to `new_compo`.
If this proxy is pointing directly to a compo, then this method is identical to `self.shallow_copy_reassign`. If, however, this proxy is a proxy tower, then all of the proxies in the tower are copied, and the bottom-most proxy is reassigned to `new_compo`.
s e l f c o p y t h i s i s r e t u r n e d p r o x y c o p y p r o x y c o p y c o m p o n e w _ c o m p o
Returns
rai.typing.Proxy
Deep copy of this proxy reassigned to `new_compo`.

def transform_point(self, point: 'rai.typing.PointLike') -> 'rai.typing.PointLike':

Apply this proxies transform to a point, return the transformed point.
A Point (tuple of two floats) is always returned, even if a BoundPoint is passed in.
Parameters
pointrai.typing.PointLike
The point to transform.
Returns
rai.typing.Point
The transformed point.

def __str__(self) -> str:

Return string representation of proxy.
Returns
str
TODO example string

def __repr__(self) -> str:

Return string representation of proxy.
Returns
str
TODO example string

def scale(self, x: float, y: float | None = None) -> Self:

Scale this proxy.
Parameters
xfloat
Factor to scale by along the x axis
yfloat
Factor to scale by along the y axis. If unspecified or None, use the x scale factor.
Returns
Self
self is returned to allow chaining methods.

def movex(self, factor: float) -> Self:

Move this proxy horizontally.
Parameters
xfloat
Move this many units along x axis.
Returns
Self
self is returned to allow chaining methods.

def movey(self, factor: float) -> Self:

Move this proxy vertically.
Parameters
yfloat
Move this many units along y axis.
Returns
Self
self is returned to allow chaining methods.

def move(self, x: float, y: float) -> Self:

Move this proxy.
Parameters
xfloat
Move this many units along x axis.
yfloat
Move this many units along y axis.
Returns
Self
self is returned to allow chaining methods.

def hflip(self, x: float = 0) -> Self:

Flip (mirror) along horizontal axis.
Parameters
xfloat
Flip around this horizontal line (x coordinate)
Returns
Self
self is returned to allow chaining methods.

def vflip(self, y: float = 0) -> Self:

Flip (mirror) along vertical axis.
Parameters
yfloat
Flip around this vertical line (y coordinate)
Returns
Self
self is returned to allow chaining methods.

def flip(self, x: float = 0, y: float = 0) -> Self:

Flip (mirror) along both horizontal and vertical axis.
Parameters
xfloat
Flip around this point (x coordinate). Default: origin
yfloat
Flip around this point (y coordinate). Default: origin
Returns
Self
self is returned to allow chaining methods.

def rotate(self, angle: float, x: float = 0, y: float = 0) -> Self:

Rotate this proxy, possibly around a point.
Parameters
anglefloat
Rotate by this many radians in the positive orientation
xfloat
Rotate around this point (x coord). Default: origin
yfloat
Rotate around this point (y coord). Default: origin
Returns
Self
self is returned to allow method chaining.

def map(self, lmap_shorthand: 'rai.typing.LMapShorthand') -> Self:

Apply a layermap shorthand to a proxy.
Parameters
lmap_shorthand
The layermap shorthand to apply
Returns
Self
self is returned to allow method chaining.

def snap_left(self, target: Self) -> Self:

Move this proxy so its bbox is to the left of the target proxy.
s e l f t a r g e t
Parameters
The target proxy
Returns
Self
This proxy is returned to allow method chaining.

def snap_right(self, target: Self) -> Self:

Move this proxy so its bbox is to the right of the target proxy.
t a r g e t s e l f
Parameters
The target proxy
Returns
Self
This proxy is returned to allow method chaining.

def snap_above(self, target: Self) -> Self:

Move this proxy so its bbox is directly above the target proxy.
s e l f t a r g e t
Parameters
The target proxy
Returns
Self
This proxy is returned to allow method chaining.

def snap_below(self, target: Self) -> Self:

Move this proxy so its bbox is directly below the target proxy.
t a r g e t s e l f
Parameters
The target proxy
Returns
Self
This proxy is returned to allow method chaining.

Property geoms

Get the raw geometries as seen through this proxy.
Returns
rai.typing.Geoms
Returns the raw geometries (i.e. NOT geometries defined in subcompos) defined in the CompoLike pointed to by this Proxy, as seen through this proxy.

Property subcompos

Get subcompos of the CompoLike pointed to by this proxy.
Returns
SubcompoContainer
A special `SubcompoContainer` is returned that is aware that you're looking at it through a proxy, so all of the subcompos will be wrapped in copies of this proxy.

Property marks

Get the marks of the CompoLike pointed to by this proxy.
Returns
ProxiedMarksContainer
A special `ProxiesMarksContainer` is returned which can be used to query the underlying CompoLike's marks as seen through this proxy.

Property bbox

Get a BoundBBox pointing to this proxy.
Returns
rai.BoundBBox
A BoundBBox pointing to this proxy