Positioning - momapy

Skip to content

# Positioning

## `` momapy.positioning

Functions for positioning layout elements and related objects relatively to other objects

Functions:

Name | Description
--- | ---
`above_left_of` | Compute and return the point above left of the given object at a given distance
`above_of` | Compute and return the point above of the given object at a given distance
`above_right_of` | Compute and return the point above right of the given object at a given distance
`below_left_of` | Compute and return the point below left of the given object at a given distance
`below_of` | Compute and return the point below of the given object at a given distance
`below_right_of` | Compute and return the point below right of the given object at a given distance
`fit` | Compute and return the bounding box fitting a collection of objects, with given margins
`fraction_of` | Return the position on an arc at a given fraction and the angle formed of the tangant of the arc at that position and the horizontal
`left_of` | Compute and return the point left of the given object at a given distance
`right_of` | Compute and return the point right of the given object at a given distance
`set_above_left_of` | Set the position of a given builder object above left of another given object at a given distance
`set_above_of` | Set the position of a given builder object above of another given object at a given distance
`set_above_right_of` | Set the position of a given builder object above right of another given object at a given distance
`set_below_left_of` | Set the position of a given builder object below left of another given object at a given distance
`set_below_of` | Set the position of a given builder object below of another given object at a given distance
`set_below_right_of` | Set the position of a given builder object below right of another given object at a given distance
`set_fit` | Set the position, width and height of a given builder object to fit a given collection of other objects
`set_fraction_of` | Set the position and rotation of a given builder object to lay at a given fraction of a given arc
`set_left_of` | Set the position of a given builder object left of another given object at a given distance
`set_position` | Set the position of a given builder object
`set_right_of` | Set the position of a given builder object right of another given object at a given distance

### `` above_left_of

    above_left_of(
        obj: Point
        | PointBuilder
        | Bbox
        | BboxBuilder
        | LayoutElement
        | LayoutElementBuilder,
        distance1: float,
        distance2: float | None = None,
    ) -> Point

Compute and return the point above left of the given object at a given distance

Source code in `src/momapy/positioning.py`

     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    def above_left_of(
        obj: (
            momapy.geometry.Point
            | momapy.geometry.PointBuilder
            | momapy.geometry.Bbox
            | momapy.geometry.BboxBuilder
            | momapy.core.LayoutElement
            | momapy.core.LayoutElementBuilder
        ),
        distance1: float,
        distance2: float | None = None,
    ) -> momapy.geometry.Point:
        """Compute and return the point above left of the given object at a given distance"""
        if distance2 is None:
            distance2 = distance1
        if momapy.builder.isinstance_or_builder(obj, momapy.geometry.Point):
            source_point = obj
        elif momapy.builder.isinstance_or_builder(obj, momapy.core.Node):
            source_point = obj.north_west()
        else:
            raise TypeError
        return source_point - (distance2, distance1)

### `` above_of

    above_of(
        obj: Point
        | PointBuilder
        | Bbox
        | BboxBuilder
        | LayoutElement
        | LayoutElementBuilder,
        distance: float,
    ) -> Point

Compute and return the point above of the given object at a given distance

Source code in `src/momapy/positioning.py`

    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    def above_of(
        obj: (
            momapy.geometry.Point
            | momapy.geometry.PointBuilder
            | momapy.geometry.Bbox
            | momapy.geometry.BboxBuilder
            | momapy.core.LayoutElement
            | momapy.core.LayoutElementBuilder
        ),
        distance: float,
    ) -> momapy.geometry.Point:
        """Compute and return the point above of the given object at a given distance"""
        if momapy.builder.isinstance_or_builder(obj, momapy.geometry.Point):
            source_point = obj
        elif momapy.builder.isinstance_or_builder(obj, momapy.core.Node):
            source_point = obj.north()
        else:
            raise TypeError
        return source_point - (0, distance)

### `` above_right_of

    above_right_of(
        obj: Point
        | PointBuilder
        | Bbox
        | BboxBuilder
        | LayoutElement
        | LayoutElementBuilder,
        distance1: float,
        distance2: float | None = None,
    ) -> Point

Compute and return the point above right of the given object at a given distance

Source code in `src/momapy/positioning.py`

    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    def above_right_of(
        obj: (
            momapy.geometry.Point
            | momapy.geometry.PointBuilder
            | momapy.geometry.Bbox
            | momapy.geometry.BboxBuilder
            | momapy.core.LayoutElement
            | momapy.core.LayoutElementBuilder
        ),
        distance1: float,
        distance2: float | None = None,
    ) -> momapy.geometry.Point:
        """Compute and return the point above right of the given object at a given distance"""
        if distance2 is None:
            distance2 = distance1
        if momapy.builder.isinstance_or_builder(obj, momapy.geometry.Point):
            source_point = obj
        elif momapy.builder.isinstance_or_builder(obj, momapy.core.Node):
            source_point = obj.north_east()
        else:
            raise TypeError
        return source_point + (distance2, -distance1)

### `` below_left_of

    below_left_of(
        obj: Point
        | PointBuilder
        | Bbox
        | BboxBuilder
        | LayoutElement
        | LayoutElementBuilder,
        distance1: float,
        distance2: float | None = None,
    ) -> Point

Compute and return the point below left of the given object at a given distance

Source code in `src/momapy/positioning.py`

    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    def below_left_of(
        obj: (
            momapy.geometry.Point
            | momapy.geometry.PointBuilder
            | momapy.geometry.Bbox
            | momapy.geometry.BboxBuilder
            | momapy.core.LayoutElement
            | momapy.core.LayoutElementBuilder
        ),
        distance1: float,
        distance2: float | None = None,
    ) -> momapy.geometry.Point:
        """Compute and return the point below left of the given object at a given distance"""
        if distance2 is None:
            distance2 = distance1
        if momapy.builder.isinstance_or_builder(obj, momapy.geometry.Point):
            source_point = obj
        elif momapy.builder.isinstance_or_builder(obj, momapy.core.Node):
            source_point = obj.south_west()
        else:
            raise TypeError
        return source_point + (-distance2, distance1)

### `` below_of

    below_of(
        obj: Point
        | PointBuilder
        | Bbox
        | BboxBuilder
        | LayoutElement
        | LayoutElementBuilder,
        distance: float,
    ) -> Point

Compute and return the point below of the given object at a given distance

Source code in `src/momapy/positioning.py`

    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    def below_of(
        obj: (
            momapy.geometry.Point
            | momapy.geometry.PointBuilder
            | momapy.geometry.Bbox
            | momapy.geometry.BboxBuilder
            | momapy.core.LayoutElement
            | momapy.core.LayoutElementBuilder
        ),
        distance: float,
    ) -> momapy.geometry.Point:
        """Compute and return the point below of the given object at a given distance"""
        if momapy.builder.isinstance_or_builder(obj, momapy.geometry.Point):
            source_point = obj
        elif momapy.builder.isinstance_or_builder(obj, momapy.core.Node):
            source_point = obj.south()
        else:
            raise TypeError
        return source_point + (0, distance)

### `` below_right_of

    below_right_of(
        obj: Point
        | PointBuilder
        | Bbox
        | BboxBuilder
        | LayoutElement
        | LayoutElementBuilder,
        distance1: float,
        distance2: float | None = None,
    ) -> Point

Compute and return the point below right of the given object at a given distance

Source code in `src/momapy/positioning.py`

    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    def below_right_of(
        obj: (
            momapy.geometry.Point
            | momapy.geometry.PointBuilder
            | momapy.geometry.Bbox
            | momapy.geometry.BboxBuilder
            | momapy.core.LayoutElement
            | momapy.core.LayoutElementBuilder
        ),
        distance1: float,
        distance2: float | None = None,
    ) -> momapy.geometry.Point:
        """Compute and return the point below right of the given object at a given distance"""
        if distance2 is None:
            distance2 = distance1
        if momapy.builder.isinstance_or_builder(obj, momapy.geometry.Point):
            source_point = obj
        elif momapy.builder.isinstance_or_builder(obj, momapy.core.Node):
            source_point = obj.south_east()
        else:
            raise TypeError
        return source_point + (distance2, distance1)

### `` fit

    fit(
        elements: Collection[
            LayoutElement
            | LayoutElementBuilder
            | Bbox
            | BboxBuilder
            | Point
            | PointBuilder
        ],
        xsep: float = 0,
        ysep: float = 0,
    ) -> Bbox

Compute and return the bounding box fitting a collection of objects, with given margins

Source code in `src/momapy/positioning.py`

    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    def fit(
        elements: collections.abc.Collection[
            momapy.core.LayoutElement
            | momapy.core.LayoutElementBuilder
            | momapy.geometry.Bbox
            | momapy.geometry.BboxBuilder
            | momapy.geometry.Point
            | momapy.geometry.PointBuilder
        ],
        xsep: float = 0,
        ysep: float = 0,
    ) -> momapy.geometry.Bbox:
        """Compute and return the bounding box fitting a collection of objects, with given margins"""
        if not elements:
            raise ValueError("elements must contain at least one element")
        points = []
        for element in elements:
            if momapy.builder.isinstance_or_builder(element, momapy.geometry.Point):
                points.append(element)
            elif momapy.builder.isinstance_or_builder(element, momapy.geometry.Bbox):
                points.append(element.north_west())
                points.append(element.south_east())
            elif momapy.builder.isinstance_or_builder(element, momapy.core.LayoutElement):
                bbox = element.bbox()
                points.append(bbox.north_west())
                points.append(bbox.south_east())
            else:
                raise TypeError(f"{type(element)} not supported")
        point = points[0]
        max_x = point.x
        max_y = point.y
        min_x = point.x
        min_y = point.y
        for point in points[1:]:
            if point.x > max_x:
                max_x = point.x
            elif point.x < min_x:
                min_x = point.x
            if point.y > max_y:
                max_y = point.y
            elif point.y < min_y:
                min_y = point.y
        max_x += xsep
        min_x -= xsep
        max_y += ysep
        min_y -= ysep
        width = max_x - min_x
        height = max_y - min_y
        bbox = momapy.geometry.Bbox(
            momapy.geometry.Point(min_x + width / 2, min_y + height / 2),
            width,
            height,
        )
        return bbox

### `` fraction_of

    fraction_of(
        arc_layout_element: SingleHeadedArc | DoubleHeadedArc,
        fraction: float,
    ) -> tuple[Point, float]

Return the position on an arc at a given fraction and the angle formed of the tangant of the arc at that position and the horizontal

Source code in `src/momapy/positioning.py`

    338
    339
    340
    341
    342
    343
    344
    def fraction_of(
        arc_layout_element: (momapy.core.SingleHeadedArc | momapy.core.DoubleHeadedArc),
        fraction: float,
    ) -> tuple[momapy.geometry.Point, float]:
        """Return the position on an arc at a given fraction and the angle formed of the tangant of the arc at that position and the horizontal"""
        position, angle = arc_layout_element.fraction(fraction)
        return position, angle

### `` left_of

    left_of(
        obj: Point
        | PointBuilder
        | Bbox
        | BboxBuilder
        | LayoutElement
        | LayoutElementBuilder,
        distance: float,
    ) -> Point

Compute and return the point left of the given object at a given distance

Source code in `src/momapy/positioning.py`

    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    def left_of(
        obj: (
            momapy.geometry.Point
            | momapy.geometry.PointBuilder
            | momapy.geometry.Bbox
            | momapy.geometry.BboxBuilder
            | momapy.core.LayoutElement
            | momapy.core.LayoutElementBuilder
        ),
        distance: float,
    ) -> momapy.geometry.Point:
        """Compute and return the point left of the given object at a given distance"""
        if momapy.builder.isinstance_or_builder(obj, momapy.geometry.Point):
            source_point = obj
        elif momapy.builder.isinstance_or_builder(obj, momapy.core.Node):
            source_point = obj.west()
        else:
            raise TypeError
        return source_point - (distance, 0)

### `` right_of

    right_of(
        obj: Point
        | PointBuilder
        | Bbox
        | BboxBuilder
        | LayoutElement
        | LayoutElementBuilder,
        distance: float,
    ) -> Point

Compute and return the point right of the given object at a given distance

Source code in `src/momapy/positioning.py`

    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    def right_of(
        obj: (
            momapy.geometry.Point
            | momapy.geometry.PointBuilder
            | momapy.geometry.Bbox
            | momapy.geometry.BboxBuilder
            | momapy.core.LayoutElement
            | momapy.core.LayoutElementBuilder
        ),
        distance: float,
    ) -> momapy.geometry.Point:
        """Compute and return the point right of the given object at a given distance"""
        if momapy.builder.isinstance_or_builder(obj, momapy.geometry.Point):
            source_point = obj
        elif momapy.builder.isinstance_or_builder(obj, momapy.core.Node):
            source_point = obj.east()
        else:
            raise TypeError
        return source_point + (distance, 0)

### `` set_above_left_of

    set_above_left_of(
        obj1: NodeBuilder | BboxBuilder,
        obj2: Point
        | PointBuilder
        | Bbox
        | BboxBuilder
        | LayoutElement
        | LayoutElementBuilder,
        distance1: float,
        distance2: float | None = None,
        anchor: str | None = None,
    )

Set the position of a given builder object above left of another given object at a given distance

Source code in `src/momapy/positioning.py`

    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    def set_above_left_of(
        obj1: momapy.core.NodeBuilder | momapy.geometry.BboxBuilder,
        obj2: (
            momapy.geometry.Point
            | momapy.geometry.PointBuilder
            | momapy.geometry.Bbox
            | momapy.geometry.BboxBuilder
            | momapy.core.LayoutElement
            | momapy.core.LayoutElementBuilder
        ),
        distance1: float,
        distance2: float | None = None,
        anchor: str | None = None,
    ):
        """Set the position of a given builder object above left of another given object at a given distance"""
        position = above_left_of(obj2, distance1, distance2)
        set_position(obj1, position, anchor)

### `` set_above_of

    set_above_of(
        obj1: NodeBuilder | BboxBuilder,
        obj2: Point
        | PointBuilder
        | Bbox
        | BboxBuilder
        | LayoutElement
        | LayoutElementBuilder,
        distance: float,
        anchor: str | None = None,
    )

Set the position of a given builder object above of another given object at a given distance

Source code in `src/momapy/positioning.py`

    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    def set_above_of(
        obj1: momapy.core.NodeBuilder | momapy.geometry.BboxBuilder,
        obj2: (
            momapy.geometry.Point
            | momapy.geometry.PointBuilder
            | momapy.geometry.Bbox
            | momapy.geometry.BboxBuilder
            | momapy.core.LayoutElement
            | momapy.core.LayoutElementBuilder
        ),
        distance: float,
        anchor: str | None = None,
    ):
        """Set the position of a given builder object above of another given object at a given distance"""
        position = above_of(obj2, distance)
        set_position(obj1, position, anchor)

### `` set_above_right_of

    set_above_right_of(
        obj1: NodeBuilder | BboxBuilder,
        obj2: Point
        | PointBuilder
        | Bbox
        | BboxBuilder
        | LayoutElement
        | LayoutElementBuilder,
        distance1: float,
        distance2: float | None = None,
        anchor: str | None = None,
    )

Set the position of a given builder object above right of another given object at a given distance

Source code in `src/momapy/positioning.py`

    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    def set_above_right_of(
        obj1: momapy.core.NodeBuilder | momapy.geometry.BboxBuilder,
        obj2: (
            momapy.geometry.Point
            | momapy.geometry.PointBuilder
            | momapy.geometry.Bbox
            | momapy.geometry.BboxBuilder
            | momapy.core.LayoutElement
            | momapy.core.LayoutElementBuilder
        ),
        distance1: float,
        distance2: float | None = None,
        anchor: str | None = None,
    ):
        """Set the position of a given builder object above right of another given object at a given distance"""
        position = above_right_of(obj2, distance1, distance2)
        set_position(obj1, position, anchor)

### `` set_below_left_of

    set_below_left_of(
        obj1: NodeBuilder | BboxBuilder,
        obj2: Point
        | PointBuilder
        | Bbox
        | BboxBuilder
        | LayoutElement
        | LayoutElementBuilder,
        distance1: float,
        distance2: float | None = None,
        anchor: str | None = None,
    )

Set the position of a given builder object below left of another given object at a given distance

Source code in `src/momapy/positioning.py`

    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    def set_below_left_of(
        obj1: momapy.core.NodeBuilder | momapy.geometry.BboxBuilder,
        obj2: (
            momapy.geometry.Point
            | momapy.geometry.PointBuilder
            | momapy.geometry.Bbox
            | momapy.geometry.BboxBuilder
            | momapy.core.LayoutElement
            | momapy.core.LayoutElementBuilder
        ),
        distance1: float,
        distance2: float | None = None,
        anchor: str | None = None,
    ):
        """Set the position of a given builder object below left of another given object at a given distance"""
        position = below_left_of(obj2, distance1, distance2)
        set_position(obj1, position, anchor)

### `` set_below_of

    set_below_of(
        obj1: NodeBuilder | BboxBuilder,
        obj2: Point
        | PointBuilder
        | Bbox
        | BboxBuilder
        | LayoutElement
        | LayoutElementBuilder,
        distance: float,
        anchor: str | None = None,
    )

Set the position of a given builder object below of another given object at a given distance

Source code in `src/momapy/positioning.py`

    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    def set_below_of(
        obj1: momapy.core.NodeBuilder | momapy.geometry.BboxBuilder,
        obj2: (
            momapy.geometry.Point
            | momapy.geometry.PointBuilder
            | momapy.geometry.Bbox
            | momapy.geometry.BboxBuilder
            | momapy.core.LayoutElement
            | momapy.core.LayoutElementBuilder
        ),
        distance: float,
        anchor: str | None = None,
    ):
        """Set the position of a given builder object below of another given object at a given distance"""
        position = below_of(obj2, distance)
        set_position(obj1, position, anchor)

### `` set_below_right_of

    set_below_right_of(
        obj1: NodeBuilder | BboxBuilder,
        obj2: Point
        | PointBuilder
        | Bbox
        | BboxBuilder
        | LayoutElement
        | LayoutElementBuilder,
        distance1: float,
        distance2: float | None = None,
        anchor: str | None = None,
    )

Set the position of a given builder object below right of another given object at a given distance

Source code in `src/momapy/positioning.py`

    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    def set_below_right_of(
        obj1: momapy.core.NodeBuilder | momapy.geometry.BboxBuilder,
        obj2: (
            momapy.geometry.Point
            | momapy.geometry.PointBuilder
            | momapy.geometry.Bbox
            | momapy.geometry.BboxBuilder
            | momapy.core.LayoutElement
            | momapy.core.LayoutElementBuilder
        ),
        distance1: float,
        distance2: float | None = None,
        anchor: str | None = None,
    ):
        """Set the position of a given builder object below right of another given object at a given distance"""
        position = below_right_of(obj2, distance1, distance2)
        set_position(obj1, position, anchor)

### `` set_fit

    set_fit(
        obj: NodeBuilder | BboxBuilder,
        elements: Collection[
            Point
            | PointBuilder
            | Bbox
            | BboxBuilder
            | LayoutElement
            | LayoutElementBuilder
        ],
        xsep: float = 0,
        ysep: float = 0,
        anchor: str | None = None,
    )

Set the position, width and height of a given builder object to fit a given collection of other objects

Source code in `src/momapy/positioning.py`

    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    def set_fit(
        obj: momapy.core.NodeBuilder | momapy.geometry.BboxBuilder,
        elements: collections.abc.Collection[
            momapy.geometry.Point
            | momapy.geometry.PointBuilder
            | momapy.geometry.Bbox
            | momapy.geometry.BboxBuilder
            | momapy.core.LayoutElement
            | momapy.core.LayoutElementBuilder
        ],
        xsep: float = 0,
        ysep: float = 0,
        anchor: str | None = None,
    ):
        """Set the position, width and height of a given builder object to fit a given collection of other objects"""
        bbox = fit(elements, xsep, ysep)
        obj.width = bbox.width
        obj.height = bbox.height
        set_position(obj, bbox.position, anchor)

### `` set_fraction_of

    set_fraction_of(
        obj: NodeBuilder,
        arc_layout_element: SingleHeadedArc | DoubleHeadedArc,
        fraction: float,
        anchor: str | None = None,
    )

Set the position and rotation of a given builder object to lay at a given fraction of a given arc

Source code in `src/momapy/positioning.py`

    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    def set_fraction_of(
        obj: momapy.core.NodeBuilder,
        arc_layout_element: (momapy.core.SingleHeadedArc | momapy.core.DoubleHeadedArc),
        fraction: float,
        anchor: str | None = None,
    ):
        """Set the position and rotation of a given builder object to lay at a given fraction of a given arc"""
        position, angle = fraction_of(arc_layout_element, fraction)
        rotation = momapy.geometry.Rotation(angle, position)
        set_position(obj, position, anchor)
        obj.transform = momapy.core.TupleBuilder([rotation])

### `` set_left_of

    set_left_of(
        obj1: NodeBuilder | BboxBuilder,
        obj2: Point
        | PointBuilder
        | Bbox
        | BboxBuilder
        | LayoutElement
        | LayoutElementBuilder,
        distance: float,
        anchor: str | None = None,
    )

Set the position of a given builder object left of another given object at a given distance

Source code in `src/momapy/positioning.py`

    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    def set_left_of(
        obj1: momapy.core.NodeBuilder | momapy.geometry.BboxBuilder,
        obj2: (
            momapy.geometry.Point
            | momapy.geometry.PointBuilder
            | momapy.geometry.Bbox
            | momapy.geometry.BboxBuilder
            | momapy.core.LayoutElement
            | momapy.core.LayoutElementBuilder
        ),
        distance: float,
        anchor: str | None = None,
    ):
        """Set the position of a given builder object left of another given object at a given distance"""
        position = left_of(obj2, distance)
        set_position(obj1, position, anchor)

### `` set_position

    set_position(
        obj: NodeBuilder | BboxBuilder,
        position: Point | PointBuilder,
        anchor: str | None = None,
    )

Set the position of a given builder object

Source code in `src/momapy/positioning.py`

    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    def set_position(
        obj: momapy.core.NodeBuilder | momapy.geometry.BboxBuilder,
        position: momapy.geometry.Point | momapy.geometry.PointBuilder,
        anchor: str | None = None,
    ):
        """Set the position of a given builder object"""
        obj.position = position
        if anchor is not None:
            p = getattr(obj, anchor)()
            obj.position += obj.position - p

### `` set_right_of

    set_right_of(
        obj1: NodeBuilder | BboxBuilder,
        obj2: Point
        | PointBuilder
        | Bbox
        | BboxBuilder
        | LayoutElement
        | LayoutElementBuilder,
        distance: float,
        anchor: str | None = None,
    )

Set the position of a given builder object right of another given object at a given distance

Source code in `src/momapy/positioning.py`

    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    def set_right_of(
        obj1: momapy.core.NodeBuilder | momapy.geometry.BboxBuilder,
        obj2: (
            momapy.geometry.Point
            | momapy.geometry.PointBuilder
            | momapy.geometry.Bbox
            | momapy.geometry.BboxBuilder
            | momapy.core.LayoutElement
            | momapy.core.LayoutElementBuilder
        ),
        distance: float,
        anchor: str | None = None,
    ):
        """Set the position of a given builder object right of another given object at a given distance"""
        position = right_of(obj2, distance)
        set_position(obj1, position, anchor)