brepjs API Reference
    Preparing search index...

    Interface DrawingPen

    DrawingPen is a helper class to draw in 2D. It is used to create drawings by exposing a builder interface. It is not a drawing itself, but it can be used to create a drawing.

    interface DrawingPen {
        _nextCorner: ((f: Curve2D, s: Curve2D) => Curve2D[]) | null;
        firstPoint: Point2D;
        pendingCurves: Curve2D[];
        pointer: Point2D;
        get penAngle(): number;
        get penPosition(): Point2D;
        _closeSketch(): void;
        _closeWithMirror(): void;
        _convertFromUV(__namedParameters: Point2D): Point2D;
        _convertToUV(__namedParameters: Point2D): Point2D;
        _customCornerLastWithFirst(
            radius: number | ((f: Curve2D, s: Curve2D) => Curve2D[]),
            mode?: "fillet" | "chamfer" | "dogbone",
        ): void;
        _lastCurve(): Curve2D | null;
        _requireLastCurve(caller: string, action: string): Curve2D;
        _resolveRelative(xDist: number, yDist: number): Point2D;
        _saveCurveAndAdvance(curve: Curve2D, end: Point2D): this;
        bezierCurveTo(end: Point2D, controlPoints: Point2D | Point2D[]): this;
        bulgeArc(xDist: number, yDist: number, bulge: number): this;
        bulgeArcTo(end: Point2D, bulge: number): this;
        close(): Drawing;
        closeWithCustomCorner(
            radius: number | ((f: Curve2D, s: Curve2D) => Curve2D[]),
            mode?: "fillet" | "chamfer" | "dogbone",
        ): Drawing;
        closeWithMirror(): Drawing;
        cubicBezierCurveTo(
            end: Point2D,
            startControlPoint: Point2D,
            endControlPoint: Point2D,
        ): this;
        customCorner(
            radius: number | ((first: Curve2D, second: Curve2D) => Curve2D[]),
            mode?: "fillet" | "chamfer",
        ): this;
        done(): Drawing;
        ellipse(
            xDist: number,
            yDist: number,
            horizontalRadius: number,
            verticalRadius: number,
            rotation?: number,
            longAxis?: boolean,
            sweep?: boolean,
        ): this;
        ellipseTo(
            end: Point2D,
            horizontalRadius: number,
            verticalRadius: number,
            rotation?: number,
            longAxis?: boolean,
            sweep?: boolean,
        ): this;
        halfEllipse(
            xDist: number,
            yDist: number,
            minorRadius: number,
            sweep?: boolean,
        ): this;
        halfEllipseTo(end: Point2D, minorRadius: number, sweep?: boolean): this;
        hBulgeArc(distance: number, bulge: number): this;
        hLine(distance: number): this;
        hLineTo(xPos: number): this;
        hSagittaArc(distance: number, sagitta: number): this;
        line(xDist: number, yDist: number): this;
        lineTo(point: Point2D): this;
        movePointerTo(point: Point2D): this;
        polarLine(distance: number, angle: number): this;
        polarLineTo(__namedParameters: Point2D): this;
        quadraticBezierCurveTo(end: Point2D, controlPoint: Point2D): this;
        sagittaArc(xDist: number, yDist: number, sagitta: number): this;
        sagittaArcTo(end: Point2D, sagitta: number): this;
        saveCurve(curve: Curve2D): void;
        smoothSpline(
            xDist: number,
            yDist: number,
            splineConfig?: SplineOptions,
        ): this;
        smoothSplineTo(end: Point2D, config?: SplineOptions): this;
        tangentArc(xDist: number, yDist: number): this;
        tangentArcTo(end: Point2D): this;
        tangentLine(distance: number): this;
        threePointsArc(
            xDist: number,
            yDist: number,
            viaXDist: number,
            viaYDist: number,
        ): this;
        threePointsArcTo(end: Point2D, midPoint: Point2D): this;
        vBulgeArc(distance: number, bulge: number): this;
        vLine(distance: number): this;
        vLineTo(yPos: number): this;
        vSagittaArc(distance: number, sagitta: number): this;
    }

    Hierarchy (View Summary)

    Implements

    Index

    Drawing State

    • get penAngle(): number

      Returns the current pen angle in degrees

      The angle represents the tangent direction at the current pen position, based on the last drawing operation (line, arc, bezier, etc.). Returns 0 if nothing has been drawn yet.

      Returns number

    Other

    _nextCorner: ((f: Curve2D, s: Curve2D) => Curve2D[]) | null
    firstPoint: Point2D
    pendingCurves: Curve2D[]
    pointer: Point2D
    • Draw an arc to a relative end point using a bulge factor.

      Parameters

      • xDist: number
      • yDist: number
      • bulge: number

      Returns this

    • Close the path and apply a custom corner treatment between the last and first segments.

      Parameters

      • radius: number | ((f: Curve2D, s: Curve2D) => Curve2D[])

        Fillet/chamfer radius.

      • mode: "fillet" | "chamfer" | "dogbone" = 'fillet'

        Corner treatment type.

      Returns Drawing

      The closed Drawing.

    • Close the path by mirroring all curves about the line from first to last point.

      Returns Drawing

    • Draw an elliptical arc to a relative end point (SVG-style parameters).

      Parameters

      • xDist: number
      • yDist: number
      • horizontalRadius: number
      • verticalRadius: number
      • rotation: number = 0
      • longAxis: boolean = false
      • sweep: boolean = false

      Returns this

    • Draw an elliptical arc to an absolute end point (SVG-style parameters).

      Parameters

      • end: Point2D
      • horizontalRadius: number
      • verticalRadius: number
      • rotation: number = 0
      • longAxis: boolean = false
      • sweep: boolean = false

      Returns this

    • Draw a half-ellipse arc to a relative end point with a given minor radius.

      Parameters

      • xDist: number
      • yDist: number
      • minorRadius: number
      • sweep: boolean = false

      Returns this

    • Draw a horizontal bulge arc of the given distance and bulge factor.

      Parameters

      • distance: number
      • bulge: number

      Returns this

    • Draw a horizontal sagitta arc of the given distance and bulge.

      Parameters

      • distance: number
      • sagitta: number

      Returns this

    • Draw a straight line by relative horizontal and vertical distances.

      Parameters

      • xDist: number
      • yDist: number

      Returns this

    • Draw a line in polar coordinates (distance and angle in degrees) from the current point.

      Parameters

      • distance: number
      • angle: number

      Returns this

    • Draw a circular arc to a relative end point, bulging by the given sagitta.

      Parameters

      • xDist: number
      • yDist: number
      • sagitta: number

      Returns this

    • Draw a circular arc tangent to the previous curve, ending at a relative offset.

      Parameters

      • xDist: number
      • yDist: number

      Returns this

    • Draw a circular arc through a via-point to an end point, both as relative distances.

      Parameters

      • xDist: number
      • yDist: number
      • viaXDist: number
      • viaYDist: number

      Returns this

    • Draw a vertical bulge arc of the given distance and bulge factor.

      Parameters

      • distance: number
      • bulge: number

      Returns this

    • Draw a vertical sagitta arc of the given distance and bulge.

      Parameters

      • distance: number
      • sagitta: number

      Returns this