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

    Function calculateTotals

    • Count the stitches in a pattern, overall and per color.

      Parameters

      • pattern: {
            colors: {
                hex?: string;
                id: number & $brand<"ColorId">;
                name: string;
                strands: {
                    brand:
                        | "Anchor"
                        | "Appletons"
                        | "Cosmo"
                        | "DMC"
                        | "J&P Coats"
                        | "Kreinik"
                        | "Madeira"
                        | "Presencia"
                        | "Sullivans"
                        | "Unbranded";
                    code: string;
                    hex?: string;
                    name: string;
                    strandCount: number;
                }[];
                symbol: string;
            }[];
            fabric?: { count: number; hex?: string; kind?: string };
            metadata?: {
                author?: string;
                copyright?: string;
                notes?: string;
                title?: string;
            };
            schemaVersion: 1;
            stitches: (
                | {
                    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 pattern to total.

      Returns PatternTotals

      The overall and per-color stitch counts.