brepjs API Reference
    Preparing search index...

    Interface Blueprint

    Represent a closed or open 2D profile as an ordered list of curves.

    A Blueprint is the fundamental 2D drawing primitive: it stores an ordered sequence of Curve2D segments that together describe a planar profile. Blueprints can be transformed (translate, rotate, scale, mirror, stretch), projected onto 3D planes or faces, combined with boolean operations, and serialized to SVG.

    Create instances via BlueprintSketcher rather than calling the constructor directly.

    const bp = new BlueprintSketcher()
    .movePointerTo([0, 0])
    .lineTo([10, 0])
    .lineTo([10, 10])
    .lineTo([0, 10])
    .close();

    // sketchOnPlane returns SketchData (wire + metadata), not a Face
    const sketch = bp.sketchOnPlane("XY");
    interface Blueprint {
        _boundingBox: BoundingBox2d | null;
        curves: Curve2D[];
        get boundingBox(): BoundingBox2d;
        get firstPoint(): Point2D;
        get lastPoint(): Point2D;
        get orientation(): "clockwise" | "counterClockwise";
        get repr(): string;
        "[dispose]"(): void;
        clone(): Blueprint;
        delete(): void;
        intersects(other: Blueprint): boolean;
        isClosed(): boolean;
        isInside(point: Point2D): boolean;
        mirror(
            centerOrDirection: Point2D,
            origin?: Point2D,
            mode?: "plane" | "center",
        ): Blueprint;
        punchHole(
            shape: AnyShape<Dimension>,
            face: SingleFace,
            options?: {
                draftAngle?: number;
                height?: number | null;
                origin?: PointInput | null;
            },
        ): AnyShape<Dimension>;
        rotate(angle: number, center?: Point2D): Blueprint;
        scale(scaleFactor: number, center?: Point2D): Blueprint;
        sketchOnFace(face: Face, scaleMode?: ScaleMode): SketchData;
        sketchOnPlane(
            inputPlane?: Plane | PlaneName,
            origin?: number | PointInput,
        ): SketchData;
        stretch(ratio: number, direction: Point2D, origin?: Point2D): Blueprint;
        toSVG(margin?: number): string;
        toSVGPath(): string;
        toSVGPathD(): string;
        toSVGPaths(): string[];
        toSVGViewBox(margin?: number): string;
        translate(xDist: number, yDist: number): Blueprint;
        translate(translationVector: Point2D): Blueprint;
    }

    Implements

    Index

    Properties

    _boundingBox: BoundingBox2d | null
    curves: Curve2D[]

    Ordered 2D curve segments that compose this blueprint.

    Accessors

    • get orientation(): "clockwise" | "counterClockwise"

      Determine the winding direction of the blueprint via the shoelace formula.

      Returns "clockwise" | "counterClockwise"

      Uses an approximation based on curve midpoints for non-linear segments. The result is cached after the first call.

    Methods

    • Test whether this blueprint's curves intersect with another blueprint's curves.

      Parameters

      Returns boolean

      Uses bounding-box pre-filtering for early rejection.

    • Test whether a 2D point lies inside this closed blueprint.

      Uses ray-casting (intersection counting) against a segment from the point to a location guaranteed to be outside the bounding box.

      Parameters

      Returns boolean

      true if the point is strictly inside the blueprint.

      Returns false for points on the boundary.

    • Mirror the blueprint across a point or plane.

      Parameters

      • centerOrDirection: Point2D

        Mirror center (center mode) or plane normal (plane mode).

      • origin: Point2D = ...

        Origin for plane-mode mirroring.

      • mode: "plane" | "center" = 'center'

        'center' for point symmetry, 'plane' for reflection across an axis.

      Returns Blueprint

      A new mirrored Blueprint.

    • Cut a prism-shaped hole through a solid along a face using this blueprint.

      Parameters

      • shape: AnyShape<Dimension>

        The solid to punch through.

      • face: SingleFace

        The face on which the hole profile is placed.

      • options: { draftAngle?: number; height?: number | null; origin?: PointInput | null } = {}

        Optional hole parameters.

        • OptionaldraftAngle?: number

          Taper angle in degrees (0 = straight hole).

        • Optionalheight?: number | null

          Hole depth; null (default) cuts through the entire solid.

        • Optionalorigin?: PointInput | null

          UV origin on the face for the blueprint placement.

      Returns AnyShape<Dimension>

      The modified shape with the hole removed.

    • Rotate the blueprint by an angle in degrees.

      Parameters

      • angle: number

        Rotation angle in degrees (positive = counter-clockwise).

      • Optionalcenter: Point2D

        Center of rotation (defaults to the origin).

      Returns Blueprint

      A new rotated Blueprint.

    • Uniformly scale the blueprint around a center point.

      Parameters

      • scaleFactor: number

        Scale multiplier (>1 enlarges, <1 shrinks).

      • Optionalcenter: Point2D

        Center of scaling (defaults to the bounding box center).

      Returns Blueprint

      A new scaled Blueprint.

    • Map this 2D blueprint onto a 3D face's UV surface.

      Parameters

      • face: Face

        Target face to project onto.

      • OptionalscaleMode: ScaleMode

        How UV coordinates are interpreted ('original', 'bounds', or 'native').

      Returns SketchData

      Sketch data containing the wire mapped onto the face.

    • Project this 2D blueprint onto a 3D plane, producing a wire and metadata.

      Parameters

      • OptionalinputPlane: Plane | PlaneName

        Named plane ("XY", "XZ", etc.) or a custom Plane.

      • Optionalorigin: number | PointInput

        Origin offset; a number sets the offset along the plane normal.

      Returns SketchData

      Sketch data containing the projected wire and default orientation.

    • Stretch the blueprint along a direction by a given ratio.

      Parameters

      • ratio: number

        Stretch factor (1 = unchanged).

      • direction: Point2D

        Unit direction vector to stretch along.

      • origin: Point2D = ...

        Fixed point of the stretch (defaults to the origin).

      Returns Blueprint

      A new stretched Blueprint.

    • Render a complete SVG document string for this blueprint.

      Parameters

      • margin: number = 1

        Extra padding around the bounding box in drawing units.

      Returns string

    • Return the SVG path d strings for this blueprint as an array.

      Returns string[]

    • Compute the SVG viewBox attribute for this blueprint.

      Parameters

      • margin: number = 1

        Extra padding around the bounding box in drawing units.

      Returns string