cross-stitch - v2.0.0
    Preparing search index...

    Function stitchBounds

    • Compute the axis-aligned bounding box of a single stitch, normalizing the two stitch shapes (cell-anchored x / y versus segment from / to) into one position-and-extent value. Cell-anchored stitches occupy the unit square at their lower-left corner; segment stitches span their two endpoints. The switch is exhaustive over Stitch kinds, so a new kind that is neither cell- nor segment-shaped fails to compile until it is handled here.

      Parameters

      • stitch:
            | {
                colorId: number & $brand<"ColorId">;
                kind: "full";
                x: number & $brand<"CellCoordinate">;
                y: number & $brand<"CellCoordinate">;
            }
            | {
                angle: "tl-br"
                | "bl-tr";
                colorId: number & $brand<"ColorId">;
                kind: "half";
                x: number & $brand<"CellCoordinate">;
                y: number & $brand<"CellCoordinate">;
            }
            | {
                colorId: number & $brand<"ColorId">;
                kind: "quarter";
                placement: "top-right" | "bottom-right" | "bottom-left" | "top-left";
                x: number & $brand<"CellCoordinate">;
                y: number & $brand<"CellCoordinate">;
            }
            | {
                angle: "tl-br"
                | "bl-tr";
                colorId: number & $brand<"ColorId">;
                kind: "three-quarter";
                placement: "top-right" | "bottom-right" | "bottom-left" | "top-left";
                x: number & $brand<"CellCoordinate">;
                y: number & $brand<"CellCoordinate">;
            }
            | {
                colorId: number & $brand<"ColorId">;
                from: {
                    x: number & $brand<"SegmentCoordinate">;
                    y: number & $brand<"SegmentCoordinate">;
                };
                kind: "back";
                to: {
                    x: number & $brand<"SegmentCoordinate">;
                    y: number & $brand<"SegmentCoordinate">;
                };
            }
            | {
                colorId: number & $brand<"ColorId">;
                from: {
                    x: number & $brand<"SegmentCoordinate">;
                    y: number & $brand<"SegmentCoordinate">;
                };
                kind: "long";
                to: {
                    x: number & $brand<"SegmentCoordinate">;
                    y: number & $brand<"SegmentCoordinate">;
                };
            }

        The stitch to measure.

      Returns StitchBounds

      The stitch's bounding box.