weasel API - v0.8.0
    Preparing search index...

    Function constrainTo45

    • Snap a (dx, dy) direction vector to the nearest 0/45/90/135° axis, preserving the input magnitude. Used by the pen tool's Shift-constrain affordance; reusable for any tool that wants axis/diagonal locking.

      Returns (0, 0) for a zero-length input (no direction to snap).

      Parameters

      • dx: number
      • dy: number

      Returns { dx: number; dy: number }