Skip to content

@eightkk/vue-weave / core / graphAlignmentGuides

Function: graphAlignmentGuides() ​

graphAlignmentGuides(moving, others, threshold): GraphAlignment

Defined in: src/core/graphSnapping.ts:90

Aligns a moving rectangle with other rectangles. On each axis the start, centre and end of moving (left, centre and right on x; top, middle and bottom on y) are compared with the same three anchors of every rectangle in others, and the smallest shift whose distance is at most threshold is returned as dx or dy (0 when nothing is close enough). Ties go to the earlier rectangle in others, then to the start, centre and end anchors of moving in that order, then to those of the other rectangle. guides lists one line per aligned position of the shifted rectangle, x guides first, each sorted by position and spanning the shifted rectangle and every rectangle aligned at that position. All values are in chart units. Throws a RangeError for a negative or non-finite threshold and for rectangles with non-finite values or a negative size.

Parameters ​

moving ​

GraphRect

others ​

readonly GraphRect[]

threshold ​

number

Returns ​

GraphAlignment

Released under the MIT License.