brepjs API Reference
    Preparing search index...

    Interface GenericSketcher<ReturnType>

    Sketchers allow the user to draw a two dimensional shape using segments of curve. You start by defining where your sketch will start (with the method movePointerTo). Each sketching method corresponds to drawing a curve of some type (line, arc, elliptic arc, bezier curve) to a new point. The next segment will start from the end point of the previous segment. Once you end your sketch you will receive a Sketch object that allows you to give some three dimensionality to your finished sketch.

    interface GenericSketcher<ReturnType> {
        bezierCurveTo(end: Point2D, controlPoints: Point2D | Point2D[]): this;
        bulgeArc(xDist: number, yDist: number, bulge: number): this;
        bulgeArcTo(end: Point2D, bulge: number): this;
        close(): ReturnType;
        closeWithMirror(): ReturnType;
        cubicBezierCurveTo(
            end: Point2D,
            startControlPoint: Point2D,
            endControlPoint: Point2D,
        ): this;
        done(): ReturnType;
        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,
            radius: number,
            sweep: boolean,
        ): this;
        halfEllipseTo(end: Point2D, radius: 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(r: number, theta: number): this;
        polarLineTo(__namedParameters: [number, number]): this;
        quadraticBezierCurveTo(end: Point2D, controlPoint: Point2D): this;
        sagittaArc(xDist: number, yDist: number, sagitta: number): this;
        sagittaArcTo(end: Point2D, sagitta: number): this;
        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, innerPoint: Point2D): this;
        vBulgeArc(distance: number, bulge: number): this;
        vLine(distance: number): this;
        vLineTo(yPos: number): this;
        vSagittaArc(distance: number, sagitta: number): this;
    }

    Type Parameters

    • ReturnType

    Implemented by

    Index

    Arc Segment

    • Draws an arc of circle by defining its end point and the bulge - the maximum distance between the arc and the straight line going from start to end point in units of half the chord. The end point is defined by its horizontal and vertical distances from the start point.

      Parameters

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

      Returns this

    • Draws an arc of circle by defining its end point and the bulge - the maximum distance between the arc and the straight line going from start to end point.

      Parameters

      Returns this

    • Draws an horizontal arc of circle by defining its end point and the bulge

      • the maximum distance between the arc and the straight line going from start to end point in units of half the chord. The end point is defined by its horizontal distance from the start point.

      Parameters

      • distance: number
      • bulge: number

      Returns this

    • Draws an horizontal arc of circle by defining its end point and the sagitta - the maximum distance between the arc and the straight line going from start to end point. The end point is defined by its horizontal distance from the start point.

      Parameters

      • distance: number
      • sagitta: number

      Returns this

    • Draws an arc of circle by defining its end point and the sagitta - the maximum distance between the arc and the straight line going from start to end point. The end point is defined by its horizontal and vertical distances from the start point.

      Parameters

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

      Returns this

    • Draws an arc of circle by defining its end point and the sagitta - the maximum distance between the arc and the straight line going from start to end point.

      Parameters

      Returns this

    • Draws an arc of circle from the current point as a tangent to the previous part of curve drawn. The end point is defined by its horizontal and vertical distances from the start point.

      Parameters

      • xDist: number
      • yDist: number

      Returns this

    • Draws an arc of circle by defining its end point and a third point through which the arc will pass. Both points are defined in horizontal (x) and vertical (y) distances from the start point.

      Parameters

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

      Returns this

    • Draws a vertical arc of circle by defining its end point and the bulge

      • the maximum distance between the arc and the straight line going from start to end point in units of half the chord. The end point is defined by its vertical distance from the start point.

      Parameters

      • distance: number
      • bulge: number

      Returns this

    • Draws a vertical arc of circle by defining its end point and the sagitta

      • the maximum distance between the arc and the straight line going from start to end point. The end point is defined by its vertical distance from the start point.

      Parameters

      • distance: number
      • sagitta: number

      Returns this

    Bezier Curve

    • Draws a generic bezier curve to the end point, going using a set of control points.

      This is the generic definition of a bezier curve, you might want to use either the quadratic or cubic (most common) version, unless you know exactly what you are aiming at.

      Parameters

      Returns this

    • Draws a cubic bezier curve to the end point, using the start and end control point to define its shape. This corresponds to the most commonly used bezier curve.

      If you are struggling setting your control points, the smoothSpline might be better for your needs.

      Parameters

      Returns this

    • Draws a cubic bezier curve to the end point, attempting to make the line smooth with the previous segment. The end point is defined by its distance to the first point.

      It will base its first control point so that its tangent is the same as the previous segment. You can force another tangent by defining startTangent.

      You can configure the tangent of the end point by configuring the endTangent, either as "symmetric" to reproduce the start angle, as an angle from the X axis (in the coordinate system) or a 2d direction (still in the coordinate system).

      The start- and end- factors decide on how far the control point is from the start and end point. At a factor of 1, the distance corresponds to a quarter of the straight line distance.

      Parameters

      Returns this

    • Draws a cubic bezier curve to the end point, attempting to make the line smooth with the previous segment.

      It will base its first control point so that its tangent is the same as the previous segment.

      The control point relative to the end is by default set to be in the direction of the straight line between start and end. You can specify the endSkew either as an angle (in degrees) to this direction, or as an absolute direction in the coordinate system (a Point).

      The start- and end- factors decide on how far the control point is from the start and end point. At a factor of 1, the distance corresponds to a quarter of the straight line distance.

      Parameters

      Returns this

    Ellipse Arc Segment

    • Draws an arc of ellipse by defining its end point and an ellipse. The end point is defined by distances from the start point.

      The shape of the ellipse is defined by both its radiuses, its angle relative to the current coordinate system, as well as the long and sweep flags (as defined for SVG paths)

      Parameters

      • xDist: number
      • yDist: number
      • horizontalRadius: number
      • verticalRadius: number
      • rotation: number
      • longAxis: boolean
      • sweep: boolean

      Returns this

    • Draws an arc of ellipse by defining its end point and an ellipse.

      The shape of the ellipse is defined by both its radiuses, its angle relative to the current coordinate system, as well as the long and sweep flags (as defined for SVG paths)

      Parameters

      • end: Point2D
      • horizontalRadius: number
      • verticalRadius: number
      • rotation: number
      • longAxis: boolean
      • sweep: boolean

      Returns this

    • Draws an arc as half an ellipse, defined by the sagitta of the ellipse (which corresponds to the radius in the axe orthogonal to the straight line). The end point is defined by distances from the start point.

      The sweep flag is to be understood as defined for SVG paths.

      Parameters

      • xDist: number
      • yDist: number
      • radius: number
      • sweep: boolean

      Returns this

    • Draws an arc as half an ellipse, defined by the sagitta of the ellipse (which corresponds to the radius in the axe orthogonal to the straight line).

      The sweep flag is to be understood as defined for SVG paths.

      Parameters

      • end: Point2D
      • radius: number
      • sweep: boolean

      Returns this

    Line Segment

    • Draws an horizontal line of length distance from the current point

      Parameters

      • distance: number

      Returns this

    • Draws a line at the horizontal distance xDist and the vertical distance yDist of the current point

      Parameters

      • xDist: number
      • yDist: number

      Returns this

    • Draws a line from the current point to the point defined in polar coordinates, of radius r and angle theta (in degrees) from the current point

      Parameters

      • r: number
      • theta: number

      Returns this

    • Draws a line from the current point to the point defined in polar coordinates, of radius r and angle theta (in degrees) from the origin

      Parameters

      • __namedParameters: [number, number]

      Returns this

    • Draws a line from the current point as a tangent to the previous part of curve drawn. The distance defines how long the line will be.

      Parameters

      • distance: number

      Returns this

    • Draws a vertical line of length distance from the current point

      Parameters

      • distance: number

      Returns this

    Other