offsetPointsToAvoidCollision
Callable
Parameters
points: Point2D[]
Original control points of the region to be pasted.
regionType: RegionType
The type of the region.
regions: RegionStore[]
All regions currently present on the target frame.
shouldApplyInitialOffset: boolean
Whether to apply one shift before collision checking.
pasteOffset: number = PASTE_OFFSET
Collision radius and shift magnitude in image pixels. Defaults to PASTE_OFFSET.
Returns Point2D[]
A new set of control points that does not collide with any existing region (or the best position found within the attempt limit).
Shifts a region's control points until its center no longer overlaps any existing region, using repeated applications of getPasteShiftDelta.
An initial shift is applied when
shouldApplyInitialOffsetistrue(i.e. the region is being pasted onto the same file it was copied from). After that, the loop continues shifting until the center is collision-free or the number of attempts exceeds the count of existing regions.Collision is defined as a Chebyshev distance smaller than
pasteOffset / 2from any valid, non-cursor region center.