Skip to main content

GenericSketcher<ReturnType>

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

Name
ReturnType

Implemented by

Arc Segment Methods

bulgeArc

bulgeArc(xDist, yDist, bulge): GenericSketcher<ReturnType>

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

NameType
xDistnumber
yDistnumber
bulgenumber

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:206


bulgeArcTo

bulgeArcTo(end, bulge): GenericSketcher<ReturnType>

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

NameType
endPoint2D
bulgenumber

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:198


hBulgeArc

hBulgeArc(distance, bulge): GenericSketcher<ReturnType>

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

NameType
distancenumber
bulgenumber

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:222


hSagittaArc

hSagittaArc(distance, sagitta): GenericSketcher<ReturnType>

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

NameType
distancenumber
sagittanumber

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:191


sagittaArc

sagittaArc(xDist, yDist, sagitta): GenericSketcher<ReturnType>

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

NameType
xDistnumber
yDistnumber
sagittanumber

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:175


sagittaArcTo

sagittaArcTo(end, sagitta): GenericSketcher<ReturnType>

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

NameType
endPoint2D
sagittanumber

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:167


tangentArc

tangentArc(xDist, yDist): GenericSketcher<ReturnType>

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

NameType
xDistnumber
yDistnumber

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:238


tangentArcTo

tangentArcTo(end): GenericSketcher<ReturnType>

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

Parameters

NameType
endPoint2D

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:230


threePointsArc

threePointsArc(xDist, yDist, viaXDist, viaYDist): GenericSketcher<ReturnType>

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

NameType
xDistnumber
yDistnumber
viaXDistnumber
viaYDistnumber

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:155


threePointsArcTo

threePointsArcTo(end, innerPoint): GenericSketcher<ReturnType>

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

Parameters

NameType
endPoint2D
innerPointPoint2D

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:148


vBulgeArc

vBulgeArc(distance, bulge): GenericSketcher<ReturnType>

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

NameType
distancenumber
bulgenumber

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:214


vSagittaArc

vSagittaArc(distance, sagitta): GenericSketcher<ReturnType>

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

NameType
distancenumber
sagittanumber

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:183


Bezier Curve Methods

bezierCurveTo

bezierCurveTo(end, controlPoints): GenericSketcher<ReturnType>

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

NameType
endPoint2D
controlPointsPoint2D | Point2D[]

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:312


cubicBezierCurveTo

cubicBezierCurveTo(end, startControlPoint, endControlPoint): GenericSketcher<ReturnType>

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

NameType
endPoint2D
startControlPointPoint2D
endControlPointPoint2D

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:328


quadraticBezierCurveTo

quadraticBezierCurveTo(end, controlPoint): GenericSketcher<ReturnType>

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

Parameters

NameType
endPoint2D
controlPointPoint2D

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:318


smoothSpline

smoothSpline(xDist, yDist, splineConfig): GenericSketcher<ReturnType>

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

NameType
xDistnumber
yDistnumber
splineConfigSplineConfig

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:370


smoothSplineTo

smoothSplineTo(end, config?): GenericSketcher<ReturnType>

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

NameType
endPoint2D
config?SplineConfig

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:350


Ellipse Arc Segment Methods

ellipse

ellipse(xDist, yDist, horizontalRadius, verticalRadius, rotation, longAxis, sweep): GenericSketcher<ReturnType>

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

NameType
xDistnumber
yDistnumber
horizontalRadiusnumber
verticalRadiusnumber
rotationnumber
longAxisboolean
sweepboolean

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:267


ellipseTo

ellipseTo(end, horizontalRadius, verticalRadius, rotation, longAxis, sweep): GenericSketcher<ReturnType>

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

NameType
endPoint2D
horizontalRadiusnumber
verticalRadiusnumber
rotationnumber
longAxisboolean
sweepboolean

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:249


halfEllipse

halfEllipse(xDist, yDist, radius, sweep): GenericSketcher<ReturnType>

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

NameType
xDistnumber
yDistnumber
radiusnumber
sweepboolean

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:296


halfEllipseTo

halfEllipseTo(end, radius, sweep): GenericSketcher<ReturnType>

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

NameType
endPoint2D
radiusnumber
sweepboolean

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:285


Line Segment Methods

hLine

hLine(distance): GenericSketcher<ReturnType>

Draws an horizontal line of length distance from the current point

Parameters

NameType
distancenumber

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:107


hLineTo

hLineTo(xPos): GenericSketcher<ReturnType>

Draws an horizontal line to the x coordinate

Parameters

NameType
xPosnumber

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:119


line

line(xDist, yDist): GenericSketcher<ReturnType>

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

Parameters

NameType
xDistnumber
yDistnumber

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:95


lineTo

lineTo(point): GenericSketcher<ReturnType>

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

Parameters

NameType
pointPoint2D

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:88


polarLine

polarLine(r, theta): GenericSketcher<ReturnType>

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

NameType
rnumber
thetanumber

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:134


polarLineTo

polarLineTo(«destructured»): GenericSketcher<ReturnType>

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

NameType
«destructured»[number, number]

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:126


tangentLine

tangentLine(distance): GenericSketcher<ReturnType>

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

NameType
distancenumber

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:141


vLine

vLine(distance): GenericSketcher<ReturnType>

Draws a vertical line of length distance from the current point

Parameters

NameType
distancenumber

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:101


vLineTo

vLineTo(yPos): GenericSketcher<ReturnType>

Draws a vertical line to the y coordinate

Parameters

NameType
yPosnumber

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:113


Other Methods

close

close(): ReturnType

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

Defined in

sketcherlib.ts:380


closeWithMirror

closeWithMirror(): ReturnType

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

Defined in

sketcherlib.ts:385


done

done(): ReturnType

Stop drawing and returns the sketch.

Returns

ReturnType

Defined in

sketcherlib.ts:375


movePointerTo

movePointerTo(point): GenericSketcher<ReturnType>

Changes the point to start your drawing from

Parameters

NameType
pointPoint2D

Returns

GenericSketcher<ReturnType>

Defined in

sketcherlib.ts:81