Skip to main content

Class: Sketcher

Defined in: Sketcher.ts:30

The FaceSketcher allows you to sketch on a plane.

Implements

Constructors

Constructor

new Sketcher(plane): Sketcher;

Defined in: Sketcher.ts:42

The sketcher can be defined by a plane, or a simple plane definition, with either a point of origin, or the position on the normal axis from the coordinates origin

Parameters

plane

Plane

Returns

Sketcher

Constructor

new Sketcher(plane?, origin?): Sketcher;

Defined in: Sketcher.ts:43

Parameters

plane?

PlaneName

origin?

number | Point

Returns

Sketcher

Arc Segment

bulgeArc()

bulgeArc(
xDist,
yDist,
bulge): this;

Defined in: Sketcher.ts:217

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

Implementation of

GenericSketcher.bulgeArc


bulgeArcTo()

bulgeArcTo(end, bulge): this;

Defined in: Sketcher.ts:208

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

Implementation of

GenericSketcher.bulgeArcTo


hBulgeArc()

hBulgeArc(distance, bulge): this;

Defined in: Sketcher.ts:226

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

Implementation of

GenericSketcher.hBulgeArc


hSagittaArc()

hSagittaArc(distance, sagitta): this;

Defined in: Sketcher.ts:204

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

Implementation of

GenericSketcher.hSagittaArc


sagittaArc()

sagittaArc(
xDist,
yDist,
sagitta): this;

Defined in: Sketcher.ts:195

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

Implementation of

GenericSketcher.sagittaArc


sagittaArcTo()

sagittaArcTo(end, sagitta): this;

Defined in: Sketcher.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.

Parameters

end

Point2D

sagitta

number

Returns

this

Implementation of

GenericSketcher.sagittaArcTo


tangentArc()

tangentArc(xDist, yDist): this;

Defined in: Sketcher.ts:170

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

Implementation of

GenericSketcher.tangentArc


tangentArcTo()

tangentArcTo(end): this;

Defined in: Sketcher.ts:158

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

Parameters

end

Point2D

Returns

this

Implementation of

GenericSketcher.tangentArcTo


threePointsArc()

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

Defined in: Sketcher.ts:145

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

Implementation of

GenericSketcher.threePointsArc


threePointsArcTo()

threePointsArcTo(end, innerPoint): this;

Defined in: Sketcher.ts:135

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

Implementation of

GenericSketcher.threePointsArcTo


vBulgeArc()

vBulgeArc(distance, bulge): this;

Defined in: Sketcher.ts:222

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

Implementation of

GenericSketcher.vBulgeArc


vSagittaArc()

vSagittaArc(distance, sagitta): this;

Defined in: Sketcher.ts:200

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

Implementation of

GenericSketcher.vSagittaArc

Bezier Curve

bezierCurveTo()

bezierCurveTo(end, controlPoints): this;

Defined in: Sketcher.ts:343

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

Implementation of

GenericSketcher.bezierCurveTo


cubicBezierCurveTo()

cubicBezierCurveTo(
end,
startControlPoint,
endControlPoint): this;

Defined in: Sketcher.ts:366

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

Implementation of

GenericSketcher.cubicBezierCurveTo


quadraticBezierCurveTo()

quadraticBezierCurveTo(end, controlPoint): this;

Defined in: Sketcher.ts:362

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

Parameters

end

Point2D

controlPoint

Point2D

Returns

this

Implementation of

GenericSketcher.quadraticBezierCurveTo


smoothSpline()

smoothSpline(
xDist,
yDist,
splineConfig): this;

Defined in: Sketcher.ts:432

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

Implementation of

GenericSketcher.smoothSpline


smoothSplineTo()

smoothSplineTo(end, config?): this;

Defined in: Sketcher.ts:374

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

Implementation of

GenericSketcher.smoothSplineTo

Ellipse Arc Segment

ellipse()

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

Defined in: Sketcher.ts:292

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 = 0

longAxis

boolean = false

sweep

boolean = false

Returns

this

Implementation of

GenericSketcher.ellipse


ellipseTo()

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

Defined in: Sketcher.ts:230

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 = 0

longAxis

boolean = false

sweep

boolean = false

Returns

this

Implementation of

GenericSketcher.ellipseTo


halfEllipse()

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

Defined in: Sketcher.ts:329

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

verticalRadius

number

sweep

boolean = false

Returns

this

Implementation of

GenericSketcher.halfEllipse


halfEllipseTo()

halfEllipseTo(
end,
verticalRadius,
sweep): this;

Defined in: Sketcher.ts:312

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

verticalRadius

number

sweep

boolean = false

Returns

this

Implementation of

GenericSketcher.halfEllipseTo

Line Segment

hLine()

hLine(distance): this;

Defined in: Sketcher.ts:89

Draws an horizontal line of length distance from the current point

Parameters

distance

number

Returns

this

Implementation of

GenericSketcher.hLine


hLineTo()

hLineTo(xPos): this;

Defined in: Sketcher.ts:98

Draws an horizontal line to the x coordinate

Parameters

xPos

number

Returns

this

Implementation of

GenericSketcher.hLineTo


line()

line(xDist, yDist): this;

Defined in: Sketcher.ts:80

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

Parameters

xDist

number

yDist

number

Returns

this

Implementation of

GenericSketcher.line


lineTo()

lineTo(__namedParameters): this;

Defined in: Sketcher.ts:73

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

Parameters

__namedParameters

Point2D

Returns

this

Implementation of

GenericSketcher.lineTo


polarLine()

polarLine(distance, angle): this;

Defined in: Sketcher.ts:103

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

distance

number

angle

number

Returns

this

Implementation of

GenericSketcher.polarLine


polarLineTo()

polarLineTo(__namedParameters): this;

Defined in: Sketcher.ts:109

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

Implementation of

GenericSketcher.polarLineTo


tangentLine()

tangentLine(distance): this;

Defined in: Sketcher.ts:115

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

Implementation of

GenericSketcher.tangentLine


vLine()

vLine(distance): this;

Defined in: Sketcher.ts:85

Draws a vertical line of length distance from the current point

Parameters

distance

number

Returns

this

Implementation of

GenericSketcher.vLine


vLineTo()

vLineTo(yPos): this;

Defined in: Sketcher.ts:93

Draws a vertical line to the y coordinate

Parameters

yPos

number

Returns

this

Implementation of

GenericSketcher.vLineTo

Other

close()

close(): Sketch;

Defined in: Sketcher.ts:483

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

Sketch

Implementation of

GenericSketcher.close


closeWithMirror()

closeWithMirror(): Sketch;

Defined in: Sketcher.ts:488

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

Returns

Sketch

Implementation of

GenericSketcher.closeWithMirror


delete()

delete(): void;

Defined in: Sketcher.ts:55

Returns

void


done()

done(): Sketch;

Defined in: Sketcher.ts:475

Stop drawing and returns the sketch.

Returns

Sketch

Implementation of

GenericSketcher.done


movePointerTo()

movePointerTo(__namedParameters): this;

Defined in: Sketcher.ts:63

Changes the point to start your drawing from

Parameters

__namedParameters

Point2D

Returns

this

Implementation of

GenericSketcher.movePointerTo