@motion-script/core / resolveShapeAnchor
Function: resolveShapeAnchor()
resolveShapeAnchor(
descriptor,width,height):object
Defined in: render/descriptors/shape.ts:115
Resolve a shape descriptor's positioning into a concrete centre x/y and
pivot (all in y-up author space), handling the cardinal-anchor shorthand.
When an anchor is present its normalised pivot a (in [-1, 1], y-up) is mapped
onto the shape's own width×height box: the centre that lands the named anchor
on target is centre = target − a · (size / 2), and pivot is set to a
(matching Node's auto-pivot). Otherwise x/y/pivot pass through unchanged —
pivot alone never repositions the shape here, since this same function re-runs
on already-resolved state (with*Descriptor is called again from
BaseShape.resolveState) and re-deriving an offset from an already-resolved
pivot would double-apply it. The pivot + plain x/y shorthand (resolvePivotPosition) bakes its offset in exactly once, before this function
ever sees the descriptor, precisely to preserve that idempotency.
Idempotent in the no-anchor case; safe to call more than once per descriptor resolve. Validates via validateShapeAnchorProps first.
Parameters
descriptor
Partial<ShapeState> & ShapeAnchorInput
width
number
height
number
Returns
object
pivot
pivot:
Anchor
x
x:
number
y
y:
number