Skip to main content

Interface: GenericSketcher<ReturnType>

Defined in: packages/replicad/src/sketcherlib.ts:77

Sketchers allow the user to draw a two dimentional shape using segment of curve. You start by defining where you 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 dimentionlity to your finished sketch.

Type Parameters​

ReturnType​

ReturnType

Arc Segment​

bulgeArc()​

bulgeArc(
xDist,
yDist,
bulge): this;

Defined in: packages/replicad/src/sketcherlib.ts:206

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


bulgeArcTo()​

bulgeArcTo(end, bulge): this;

Defined in: packages/replicad/src/sketcherlib.ts:198

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​

end​

Point2D

bulge​

number

Returns​

this


hBulgeArc()​

hBulgeArc(distance, bulge): this;

Defined in: packages/replicad/src/sketcherlib.ts:222

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


hSagittaArc()​

hSagittaArc(distance, sagitta): this;

Defined in: packages/replicad/src/sketcherlib.ts:191

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


sagittaArc()​

sagittaArc(
xDist,
yDist,
sagitta): this;

Defined in: packages/replicad/src/sketcherlib.ts:175

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


sagittaArcTo()​

sagittaArcTo(end, sagitta): this;

Defined in: packages/replicad/src/sketcherlib.ts:167

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​

end​

Point2D

sagitta​

number

Returns​

this


tangentArc()​

tangentArc(xDist, yDist): this;

Defined in: packages/replicad/src/sketcherlib.ts:238

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


tangentArcTo()​

tangentArcTo(end): this;

Defined in: packages/replicad/src/sketcherlib.ts:230

Draws an arc of circle from the current point as a tangent to the previous part of curve drawn.

Parameters​

end​

Point2D

Returns​

this


threePointsArc()​

threePointsArc(
xDist,
yDist,
viaXDist,
viaYDist): this;

Defined in: packages/replicad/src/sketcherlib.ts:155

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

Parameters​

xDist​

number

yDist​

number

viaXDist​

number

viaYDist​

number

Returns​

this


threePointsArcTo()​

threePointsArcTo(end, innerPoint): this;

Defined in: packages/replicad/src/sketcherlib.ts:148

Draws an arc of circle by defining its end point and a third point through which the arc will pass.

Parameters​

end​

Point2D

innerPoint​

Point2D

Returns​

this


vBulgeArc()​

vBulgeArc(distance, bulge): this;

Defined in: packages/replicad/src/sketcherlib.ts:214

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


vSagittaArc()​

vSagittaArc(distance, sagitta): this;

Defined in: packages/replicad/src/sketcherlib.ts:183

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​

bezierCurveTo()​

bezierCurveTo(end, controlPoints): this;

Defined in: packages/replicad/src/sketcherlib.ts:312

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

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

Parameters​

end​

Point2D

controlPoints​

| Point2D | Point2D[]

Returns​

this


cubicBezierCurveTo()​

cubicBezierCurveTo(
end,
startControlPoint,
endControlPoint): this;

Defined in: packages/replicad/src/sketcherlib.ts:328

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​

end​

Point2D

startControlPoint​

Point2D

endControlPoint​

Point2D

Returns​

this


quadraticBezierCurveTo()​

quadraticBezierCurveTo(end, controlPoint): this;

Defined in: packages/replicad/src/sketcherlib.ts:318

Draws a quadratic bezier curve to the end point, using the single control point.

Parameters​

end​

Point2D

controlPoint​

Point2D

Returns​

this


smoothSpline()​

smoothSpline(
xDist,
yDist,
splineConfig): this;

Defined in: packages/replicad/src/sketcherlib.ts:370

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 than 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​

xDist​

number

yDist​

number

splineConfig​

SplineConfig

Returns​

this


smoothSplineTo()​

smoothSplineTo(end, config?): this;

Defined in: packages/replicad/src/sketcherlib.ts:350

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 than 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 specifiy 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​

end​

Point2D

config?​

SplineConfig

Returns​

this

Ellipse Arc Segment​

ellipse()​

ellipse(
xDist,
yDist,
horizontalRadius,
verticalRadius,
rotation,
longAxis,
sweep): this;

Defined in: packages/replicad/src/sketcherlib.ts:267

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

The shape of the ellipse is defined by both its radiuses, its angle relative to the current coordinat 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


ellipseTo()​

ellipseTo(
end,
horizontalRadius,
verticalRadius,
rotation,
longAxis,
sweep): this;

Defined in: packages/replicad/src/sketcherlib.ts:249

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 coordinat 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


halfEllipse()​

halfEllipse(
xDist,
yDist,
radius,
sweep): this;

Defined in: packages/replicad/src/sketcherlib.ts:296

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 he 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


halfEllipseTo()​

halfEllipseTo(
end,
radius,
sweep): this;

Defined in: packages/replicad/src/sketcherlib.ts:285

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​

hLine()​

hLine(distance): this;

Defined in: packages/replicad/src/sketcherlib.ts:107

Draws an horizontal line of length distance from the current point

Parameters​

distance​

number

Returns​

this


hLineTo()​

hLineTo(xPos): this;

Defined in: packages/replicad/src/sketcherlib.ts:119

Draws an horizontal line to the x coordinate

Parameters​

xPos​

number

Returns​

this


line()​

line(xDist, yDist): this;

Defined in: packages/replicad/src/sketcherlib.ts:95

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

Parameters​

xDist​

number

yDist​

number

Returns​

this


lineTo()​

lineTo(point): this;

Defined in: packages/replicad/src/sketcherlib.ts:88

Draws a line from the current point to the point given in argument

Parameters​

point​

Point2D

Returns​

this


polarLine()​

polarLine(r, theta): this;

Defined in: packages/replicad/src/sketcherlib.ts:134

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

Parameters​

r​

number

theta​

number

Returns​

this


polarLineTo()​

polarLineTo(__namedParameters): this;

Defined in: packages/replicad/src/sketcherlib.ts:126

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

Parameters​

__namedParameters​

[number, number]

Returns​

this


tangentLine()​

tangentLine(distance): this;

Defined in: packages/replicad/src/sketcherlib.ts:141

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


vLine()​

vLine(distance): this;

Defined in: packages/replicad/src/sketcherlib.ts:101

Draws a vertical line of length distance from the current point

Parameters​

distance​

number

Returns​

this


vLineTo()​

vLineTo(yPos): this;

Defined in: packages/replicad/src/sketcherlib.ts:113

Draws a vertical line to the y coordinate

Parameters​

yPos​

number

Returns​

this

Other​

close()​

close(): ReturnType;

Defined in: packages/replicad/src/sketcherlib.ts:380

Stop drawing, make sure the sketch is closed (by adding a straight line to from the last point to the first) and returns the sketch.

Returns​

ReturnType


closeWithMirror()​

closeWithMirror(): ReturnType;

Defined in: packages/replicad/src/sketcherlib.ts:385

Stop drawing, make sure the sketch is closed (by mirroring the lines between the first and last points drawn) and returns the sketch.

Returns​

ReturnType


done()​

done(): ReturnType;

Defined in: packages/replicad/src/sketcherlib.ts:375

Stop drawing and returns the sketch.

Returns​

ReturnType


movePointerTo()​

movePointerTo(point): this;

Defined in: packages/replicad/src/sketcherlib.ts:81

Changes the point to start your drawing from

Parameters​

point​

Point2D

Returns​

this