Skip to content
On this page

Style Functions

Constraint Functions

collinear

collinear(c1, c2, c3): IVarAD

Require that three points be collinear. Depends on the specific ordering of points.

Parameters

NameType
c1IVarAD[]
c2IVarAD[]
c3IVarAD[]

Returns

IVarAD

Defined in

contrib/Constraints.ts:420


collinearUnordered

collinearUnordered(c1, c2, c3): IVarAD

Require that three points be collinear. Does not enforce a specific ordering of points, instead it takes the arrangement of points that is most easily satisfiable.

Parameters

NameType
c1IVarAD[]
c2IVarAD[]
c3IVarAD[]

Returns

IVarAD

Defined in

contrib/Constraints.ts:436


disjointScalar

disjointScalar(c, left, right): IVarAD

Make scalar c disjoint from a range left, right.

Parameters

NameType
cany
leftany
rightany

Returns

IVarAD

Defined in

contrib/Constraints.ts:395


perpendicular

perpendicular(q, p, r): IVarAD

Require that the vector defined by (q, p) is perpendicular from the vector defined by (r, p).

Parameters

NameType
qIVarAD[]
pIVarAD[]
rIVarAD[]

Returns

IVarAD

Defined in

contrib/Constraints.ts:409


atDist

Static atDist(__namedParameters, __namedParameters, distance): IVarAD

Require that shape s1 is at a distance of distance from shape s2.

Parameters

NameType
__namedParameters[string, any]
__namedParameters[string, any]
distancenumber

Returns

IVarAD

Defined in

contrib/Constraints.ts:571


contains

Static contains(__namedParameters, __namedParameters, padding?): IVarAD

Require that a shape s1 contains another shape s2, based on the type of the shape, and with an optional padding between the sizes of the shapes (e.g. if s1 should contain s2 with margin padding).

Parameters

NameTypeDefault value
__namedParameters[string, any]undefined
__namedParameters[string, any]undefined
paddingnumber0.0

Returns

IVarAD

Defined in

contrib/Constraints.ts:548


contains1D

Static contains1D(__namedParameters, __namedParameters): IVarAD

Require that an interval [l1, r1] contains another interval [l2, r2]. If not possible, returns 0.

Parameters

NameType
__namedParameters[IVarAD, IVarAD]
__namedParameters[IVarAD, IVarAD]

Returns

IVarAD

Defined in

contrib/Constraints.ts:384


disjoint

Static disjoint(__namedParameters, __namedParameters, padding?): IVarAD

Require that a shape s1 is disjoint from shape s2, based on the type of the shape, and with an optional padding between them (e.g. if s1 should be disjoint from s2 with margin padding).

Parameters

NameTypeDefault value
__namedParameters[string, any]undefined
__namedParameters[string, any]undefined
paddingnumber0.0

Returns

IVarAD

Defined in

contrib/Constraints.ts:522


disjointIntervals

Static disjointIntervals(__namedParameters, __namedParameters): IVarAD

Make two intervals disjoint. They must be 1D intervals (line-like shapes) sharing a y-coordinate.

Parameters

NameType
__namedParameters[string, any]
__namedParameters[string, any]

Returns

IVarAD

Defined in

contrib/Constraints.ts:611


equal

Static equal(x, y): IVarAD

Require that the value x is equal to the value y

Parameters

NameType
xIVarAD
yIVarAD

Returns

IVarAD

Defined in

contrib/Constraints.ts:341


greaterThan

Static greaterThan(x, y, padding?): IVarAD

Require that the value x is greater than the value y with optional padding padding

Parameters

NameTypeDefault value
xIVarADundefined
yIVarADundefined
paddingnumber0

Returns

IVarAD

Defined in

contrib/Constraints.ts:355


greaterThanSq

Static greaterThanSq(x, y): IVarAD

Require that the value x is greater than the value y, with steeper penalty

Parameters

NameType
xIVarAD
yIVarAD

Returns

IVarAD

Defined in

contrib/Constraints.ts:370


inRange

Static inRange(x, x0, x1): IVarAD

Require that the value x is in the range defined by [x0, x1].

Parameters

NameType
xIVarAD
x0IVarAD
x1IVarAD

Returns

IVarAD

Defined in

contrib/Constraints.ts:377


lessThan

Static lessThan(x, y, padding?): IVarAD

Require that the value x is less than the value y with optional padding padding

Parameters

NameTypeDefault value
xIVarADundefined
yIVarADundefined
paddingnumber0

Returns

IVarAD

Defined in

contrib/Constraints.ts:348


lessThanSq

Static lessThanSq(x, y): IVarAD

Require that the value x is less than the value y, with steeper penalty

Parameters

NameType
xIVarAD
yIVarAD

Returns

IVarAD

Defined in

contrib/Constraints.ts:362


maxSize

Static maxSize(__namedParameters, limit): IVarAD

Require that a shape have a size less than some constant maximum, based on the type of the shape.

Parameters

NameType
__namedParameters[string, any]
limitnumber | IVarAD

Returns

IVarAD

Defined in

contrib/Constraints.ts:482


minSize

Static minSize(__namedParameters, limit?): IVarAD

Require that a shape have a size greater than some constant minimum, based on the type of the shape.

Parameters

NameTypeDefault value
__namedParameters[string, any]undefined
limitnumber50

Returns

IVarAD

Defined in

contrib/Constraints.ts:475


onCanvas

Static onCanvas(__namedParameters, canvasWidth, canvasHeight): IVarAD

Require that shape is on the canvas

Parameters

NameType
__namedParametersany
canvasWidthIVarAD
canvasHeightIVarAD

Returns

IVarAD

Defined in

contrib/Constraints.ts:453


overlapping

Static overlapping(__namedParameters, __namedParameters, overlap?): IVarAD

Require that shape s1 overlaps shape s2 with some overlap overlap. based on the type of the shape, and with an optional overlap between them (e.g. if s1 should be overlapping s2 with margin overlap).

Parameters

NameTypeDefault value
__namedParameters[string, any]undefined
__namedParameters[string, any]undefined
paddingnumber0.0

Returns

IVarAD

Defined in

contrib/Constraints.ts:491


smallerThan

Static smallerThan(__namedParameters, __namedParameters, relativePadding?): IVarAD

Require that shape s1 is smaller than s2 with some relative padding relativePadding.

Parameters

NameTypeDefault value
__namedParameters[string, any]undefined
__namedParameters[string, any]undefined
relativePaddingnumber0.4

Returns

IVarAD

Defined in

contrib/Constraints.ts:584


touching

Static touching(__namedParameters, __namedParameters, padding?): IVarAD

Require that shape s1 is touching shape s2. based on the type of the shape, and with an optional padding between them (e.g. if s1 should be touching s2 with margin padding).

Parameters

NameTypeDefault value
__namedParameters[string, any]undefined
__namedParameters[string, any]undefined
paddingnumber0.0

Returns

IVarAD

Defined in

contrib/Constraints.ts:535

Objective Functions

above

Static above(__namedParameters, __namedParameters, offset?): IVarAD

Encourage the center of sBottom to be below the center of sTop.

Parameters

NameTypeDefault value
__namedParameters[string, any]undefined
__namedParameters[string, any]undefined
offsetnumber100

Returns

IVarAD

Defined in

contrib/Objectives.ts:396


below

Static below(__namedParameters, __namedParameters, offset?): IVarAD

Encourage the center of sTop to be above the center of sBottom. Only works for shapes with property center.

Parameters

NameTypeDefault value
__namedParameters[string, any]undefined
__namedParameters[string, any]undefined
offsetnumber100

Returns

IVarAD

Defined in

contrib/Objectives.ts:380


centerArrow

Static centerArrow(__namedParameters, __namedParameters, __namedParameters): IVarAD

Try to center the arrow arr between the shapes s2 and s3 (they can also be any shapes with a center).

Parameters

NameType
__namedParameters[string, any]
__namedParameters[string, any]
__namedParameters[string, any]

Returns

IVarAD

Defined in

contrib/Objectives.ts:528


centerLabel

Static centerLabel(__namedParameters, __namedParameters, w, padding?): IVarAD

Try to center a label s2 with respect to some shape s1.

Parameters

NameTypeDefault value
__namedParameters[string, any]undefined
__namedParameters[string, any]undefined
wnumberundefined
paddingnumber10

Returns

IVarAD

Defined in

contrib/Objectives.ts:580


centerLabelAbove

Static centerLabelAbove(__namedParameters, __namedParameters, w): IVarAD

Parameters

NameType
__namedParameters[string, any]
__namedParameters[string, any]
wnumber

Returns

IVarAD

Defined in

contrib/Objectives.ts:551


equal

Static equal(x, y): IVarAD

Encourage the inputs to have the same value: (x - y)^2

Parameters

NameType
xIVarAD
yIVarAD

Returns

IVarAD

Defined in

contrib/Objectives.ts:346


greaterThan

Static greaterThan(x, y): IVarAD

Encourage x to be greater than or equal to y: max(0,y - x)^2

Parameters

NameType
xIVarAD
yIVarAD

Returns

IVarAD

Defined in

contrib/Objectives.ts:351


leftwards

Static leftwards(__namedParameters, __namedParameters, offset?): IVarAD

Encourage the center of sLeft to be leftwards to the center of sRight.

Parameters

NameTypeDefault value
__namedParameters[string, any]undefined
__namedParameters[string, any]undefined
offsetnumber100

Returns

IVarAD

Defined in

contrib/Objectives.ts:412


lessThan

Static lessThan(x, y): IVarAD

Encourage x to be less than or equal to y: max(0,x - y)^2

Parameters

NameType
xIVarAD
yIVarAD

Returns

IVarAD

Defined in

contrib/Objectives.ts:356


maximal

Static maximal(x): IVarAD

Encourage the input value to be close to infinity

Parameters

NameType
xIVarAD

Returns

IVarAD

Defined in

contrib/Objectives.ts:341


minimal

Static minimal(x): IVarAD

Encourage the input value to be close to negative infinity

Parameters

NameType
xIVarAD

Returns

IVarAD

Defined in

contrib/Objectives.ts:336


near

Static near(__namedParameters, __namedParameters, offset?): IVarAD

Try to place shape s1 near shape s2 (putting their centers at the same place).

Parameters

NameTypeDefault value
__namedParameters[string, any]undefined
__namedParameters[string, any]undefined
offsetnumber10.0

Returns

IVarAD

Defined in

contrib/Objectives.ts:481


nearPt

Static nearPt(__namedParameters, x, y): IVarAD

Try to place shape s1 near a location (x, y).

Parameters

NameType
__namedParameters[string, any]
xany
yany

Returns

IVarAD

Defined in

contrib/Objectives.ts:491


nonDegenerateAngle

Static nonDegenerateAngle(__namedParameters, __namedParameters, __namedParameters, strength?, range?): IVarAD

Repel the angle between the p1-p0 and p1-p2 away from 0 and 180 degrees. NOTE: angles more than range degrees from 0 or 180 deg are considered satisfied.

Parameters

NameTypeDefault value
__namedParameters[string, any]undefined
__namedParameters[string, any]undefined
__namedParameters[string, any]undefined
strengthnumber20
rangenumber10

Returns

IVarAD

Defined in

contrib/Objectives.ts:499


pointLineDist

Static pointLineDist(point, __namedParameters, padding): IVarAD

try to make distance between a point and a segment s1 = padding.

Parameters

NameType
pointIVarAD[]
__namedParameters[string, any]
paddingIVarAD

Returns

IVarAD

Defined in

contrib/Objectives.ts:609


repel

Static repel(__namedParameters, __namedParameters, weight?): IVarAD

Try to repel shapes s1 and s2 with some weight.

Parameters

NameTypeDefault value
__namedParameters[string, any]undefined
__namedParameters[string, any]undefined
weightnumber10.0

Returns

IVarAD

Defined in

contrib/Objectives.ts:453


repelPt

Static repelPt(weight, a, b): IVarAD

Repel point a from another scalar b with weight weight.

Parameters

NameType
weightIVarAD
aIVarAD[]
bIVarAD[]

Returns

IVarAD

Defined in

contrib/Objectives.ts:361


repelScalar

Static repelScalar(c, d): IVarAD

Repel scalar c from another scalar d.

Parameters

NameType
cnumber | IVarAD
dnumber | IVarAD

Returns

IVarAD

Defined in

contrib/Objectives.ts:367


rightwards

Static rightwards(__namedParameters, __namedParameters, offset?): IVarAD

Encourage the center of sRight to be rightwards to the center of sLeft.

Parameters

NameTypeDefault value
__namedParameters[string, any]undefined
__namedParameters[string, any]undefined
offsetnumber100

Returns

IVarAD

Defined in

contrib/Objectives.ts:428


sameCenter

Static sameCenter(__namedParameters, __namedParameters): IVarAD

Encourage shape s1 to have the same center position as shape s2.

Parameters

NameType
__namedParameters[string, any]
__namedParameters[string, any]

Returns

IVarAD

Defined in

contrib/Objectives.ts:444

Computation Functions

MathE

Static MathE(_context): IFloatV<IVarAD>

Base e of the natural logarithm.

Parameters

NameType
_contextContext

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2942


MathPI

Static MathPI(_context): IFloatV<IVarAD>

Ratio of the circumference of a circle to its diameter.

Parameters

NameType
_contextContext

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2952


abs

Static abs(_context, x): IFloatV<IVarAD>

Return the absolute value of the number x.

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2874


acos

Static acos(_context, x): IFloatV<IVarAD>

Return acos(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1787


acosh

Static acosh(_context, x): IFloatV<IVarAD>

Return acosh(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1777


angleBetween

Static angleBetween(_context, u, v): IFloatV<IVarAD>

Return the unsigned angle between vectors u, v, in radians. Assumes that both u and v have nonzero magnitude. The returned value will be in the range [0,pi].

Parameters

NameType
_contextContext
uIVarAD[]
vIVarAD[]

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2292


angleFrom

Static angleFrom(_context, u, v): IFloatV<IVarAD>

Return the signed angle from vector u to vector v, in radians. Assumes that both u and v are 2D vectors and have nonzero magnitude. The returned value will be in the range [-pi,pi].

Parameters

NameType
_contextContext
uIVarAD[]
vIVarAD[]

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2305


angleOf

Static angleOf(_context, v): IFloatV<IVarAD>

Return the angle made by the vector v with the positive x-axis.

Parameters

NameType
_contextContext
vIVarAD[]

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2933


arc

Static arc(_context, pathType, start, end, radius, rotation, largeArc, arcSweep): IPathDataV<IVarAD>

Return series of elements that can render an arc SVG. See: https://css-tricks.com/svg-path-syntax-illustrated-guide/ for the "A" spec.

returns: Elements that can be passed to Path shape spec to render an SVG arc

Parameters

NameType
_contextContext
pathTypestring
startPt2
endPt2
radiusPt2
rotationIVarAD
largeArcIVarAD
arcSweepIVarAD

Returns

IPathDataV<IVarAD>

Defined in

contrib/Functions.ts:2201


arcSweepFlag

Static arcSweepFlag(_context, __namedParameters, start, end): IFloatV<IVarAD>

Return 0 if direction of rotation is CCW, 1 if direction of rotation is CW.

returns: 0 or 1 depending on CCW or CW rotation

Parameters

NameType
_contextContext
__namedParametersIVarAD[]
startPt2
endPt2

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2272


asin

Static asin(_context, x): IFloatV<IVarAD>

Return asin(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1797


asinh

Static asinh(_context, x): IFloatV<IVarAD>

Return asinh(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1807


atan

Static atan(_context, x): IFloatV<IVarAD>

Return atan(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1817


atan2

Static atan2(_context, x, y): IFloatV<IVarAD>

Return atan2(y,x).

Parameters

NameType
_contextContext
xIVarAD
yIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1827


atanh

Static atanh(_context, x): IFloatV<IVarAD>

Return atanh(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1837


average

Static average(_context, xs): IFloatV<IVarAD>

Return the average of the floats in the list xs.

Parameters

NameType
_contextContext
xsIVarAD[]

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2589


average2

Static average2(_context, x, y): IFloatV<IVarAD>

Return the average of floats x and y.

Parameters

NameType
_contextContext
xIVarAD
yIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2579


barycenter

Static barycenter(_context, a, b, c): IVectorV<IVarAD>

Return the barycenter of the triangle with vertices a, b, c.

Parameters

NameType
_contextContext
aIVarAD[]
bIVarAD[]
cIVarAD[]

Returns

IVectorV<IVarAD>

Defined in

contrib/Functions.ts:2690


cbrt

Static cbrt(_context, x): IFloatV<IVarAD>

Return cbrt(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1847


ceil

Static ceil(_context, x): IFloatV<IVarAD>

Return ceil(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1857


checkFloat

Static checkFloat(x): void

Parameters

NameType
xany

Returns

void

Defined in

contrib/Functions.ts:2985


chevron

Static chevron(_context, __namedParameters, padding, ticks): IPtListV<IVarAD>

Parameters

NameType
_contextContext
__namedParameters[string, any]
paddingIVarAD
ticksIVarAD

Returns

IPtListV<IVarAD>

Defined in

contrib/Functions.ts:2385


circumcenter

Static circumcenter(_context, p, q, r): IVectorV<IVarAD>

Return the circumcenter of the triangle with vertices p, q, r.

Parameters

NameType
_contextContext
pIVarAD[]
qIVarAD[]
rIVarAD[]

Returns

IVectorV<IVarAD>

Defined in

contrib/Functions.ts:2706


circumradius

Static circumradius(_context, p, q, r): IFloatV<IVarAD>

Return the circumradius of the triangle with vertices p, q, r.

Parameters

NameType
_contextContext
pIVarAD[]
qIVarAD[]
rIVarAD[]

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2748


concat

Static concat(_context, ...strings): IStrV

Concatenate a list of strings

Parameters

NameType
_contextContext
...stringsstring[]

Returns

IStrV

Defined in

contrib/Functions.ts:2072


cos

Static cos(_context, x): IFloatV<IVarAD>

Return cos(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1867


cosh

Static cosh(_context, x): IFloatV<IVarAD>

Return cosh(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1877


cross2D

Static cross2D(_context, u, v): IFloatV<IVarAD>

Return the 2D cross product of u and v, equal to the determinant of the 2x2 matrix [u v]

Parameters

NameType
_contextContext
uIVarAD[]
vIVarAD[]

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2316


cubicCurveFromPoints

Static cubicCurveFromPoints(_context, pathType, pts): IPathDataV<IVarAD>

Given a list of points pts, returns a PathData that can be used as input to the Path shape's pathData attribute to be drawn on the screen.

Parameters

NameType
_contextContext
pathTypestring
ptsPt2[]

Returns

IPathDataV<IVarAD>

Defined in

contrib/Functions.ts:2125


derivative

Static derivative(_context, optDebugInfo, varName): IFloatV<any>

Return the derivative of varName. NOTE: This is a special system function. Don't change it!

Parameters

NameType
_contextContext
optDebugInfoIOptDebugInfo
varNamestring

Returns

IFloatV<any>

Defined in

contrib/Functions.ts:1612


derivativePreconditioned

Static derivativePreconditioned(_context, optDebugInfo, varName): IFloatV<any>

Return the L-BFGS preconditioned derivative of varName. NOTE: This is a special system function. Don't change it!

Parameters

NameType
_contextContext
optDebugInfoIOptDebugInfo
varNamestring

Returns

IFloatV<any>

Defined in

contrib/Functions.ts:1651


dot

Static dot(_context, v, w): IFloatV<IVarAD>

Return the dot product of v and w.

Parameters

NameType
_contextContext
vIVarAD[]
wIVarAD[]

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2037


exp

Static exp(_context, x): IFloatV<IVarAD>

Return exp(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1887


expm1

Static expm1(_context, x): IFloatV<IVarAD>

Return expm1(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1897


floor

Static floor(_context, x): IFloatV<IVarAD>

Return floor(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1907


furthestFrom

Static furthestFrom(pts, candidates): IVarAD[]

Returns the point in candidates farthest from the points in pts (by sum). Note: With the current autodiff system you cannot make discrete choices -- TODO debug why this code doesn't terminate in objective/gradient compilation Do not use this!

Parameters

NameType
ptsIVarAD[][]
candidatesIVarAD[][]

Returns

IVarAD[]

Defined in

contrib/Functions.ts:3042


get

Static get(_context, xs, i): IFloatV<any>

Return ith element of list `xs, assuming lists only hold floats.

Parameters

NameType
_contextContext
xsIVarAD[]
inumber

Returns

IFloatV<any>

Defined in

contrib/Functions.ts:1691


getVar

Static getVar(_context, xs, i): IFloatV<any>

Parameters

NameType
_contextContext
xsIVarAD[]
iIVarAD

Returns

IFloatV<any>

Defined in

contrib/Functions.ts:1699


hsva

Static hsva(_context, h, s, v, a): IColorV<IVarAD>

Return a paint color of elements h, s, v, a (hue, saturation, value, opacity).

Parameters

NameType
_contextContext
hIVarAD
sIVarAD
vIVarAD
aIVarAD

Returns

IColorV<IVarAD>

Defined in

contrib/Functions.ts:1746


incenter

Static incenter(_context, p, q, r): IVectorV<IVarAD>

Return the incenter of the triangle with vertices p, q, r.

Parameters

NameType
_contextContext
pIVarAD[]
qIVarAD[]
rIVarAD[]

Returns

IVectorV<IVarAD>

Defined in

contrib/Functions.ts:2786


innerPointOffset

Static innerPointOffset(_context, pt1, pt2, pt3, padding): IVectorV<IVarAD>

Return a point located at padding of a line s1 offset by padding in its normal direction (for making right angle markers).

Parameters

NameType
_contextContext
pt1IVarAD[]
pt2IVarAD[]
pt3IVarAD[]
paddingIVarAD

Returns

IVectorV<IVarAD>

Defined in

contrib/Functions.ts:2416


inradius

Static inradius(_context, p, q, r): IFloatV<IVarAD>

Return the inradius of the triangle with vertices p, q, r.

Parameters

NameType
_contextContext
pIVarAD[]
qIVarAD[]
rIVarAD[]

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2818


intersectingSideSize

Static intersectingSideSize(_context, start, end, __namedParameters): IFloatV<IVarAD>

Figure out which side of the rectangle [t1, s1] the start->end line is hitting, assuming that start is located at the rect's center and end is located outside the rectangle, and return the size of the OTHER side. Also assuming axis-aligned rectangle. This is used for arrow placement in box-and-arrow diagrams.

deprecated Don't use this function, it does not fully work

Parameters

NameType
_contextContext
startVecAD
endVecAD
__namedParameters[string, any]

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2518


length

Static length(_context, __namedParameters): IFloatV<IVarAD>

Return the length of the line or arrow shape [type, props].

Parameters

NameType
_contextContext
__namedParameters[string, any]

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2061


lineLength

Static lineLength(_context, __namedParameters): IFloatV<IVarAD>

Return the length of the line or arrow shape [type, props].

Parameters

NameType
_contextContext
__namedParameters[string, any]

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2047


lineLineIntersection

Static lineLineIntersection(_context, a0, a1, b0, b1): IVectorV<IVarAD>

Return the intersection of a line passing through a0 and a1 with a line passing through b0 and b1

Parameters

NameType
_contextContext
a0IVarAD[]
a1IVarAD[]
b0IVarAD[]
b1IVarAD[]

Returns

IVectorV<IVarAD>

Defined in

contrib/Functions.ts:2328


log

Static log(_context, x): IFloatV<IVarAD>

Return log(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1917


log10

Static log10(_context, x): IFloatV<IVarAD>

Return log10(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1937


log1p

Static log1p(_context, x): IFloatV<IVarAD>

Return log1p(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1947


log2

Static log2(_context, x): IFloatV<IVarAD>

Return log2(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1927


makePath

Static makePath(_context, start, end, curveHeight, padding): IPathDataV<IVarAD>

Parameters

NameType
_contextContext
start[IVarAD, IVarAD]
end[IVarAD, IVarAD]
curveHeightIVarAD
paddingIVarAD

Returns

IPathDataV<IVarAD>

Defined in

contrib/Functions.ts:1582


max

Static max(_context, x, y): IFloatV<IVarAD>

Return the max of the numbers x, y.

Parameters

NameType
_contextContext
xIVarAD
yIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2860


midpoint

Static midpoint(_context, start, end): IVectorV<IVarAD>

Return a point located at the midpoint between pts start and end

Parameters

NameType
_contextContext
startIVarAD[]
endIVarAD[]

Returns

IVectorV<IVarAD>

Defined in

contrib/Functions.ts:2350


midpointOffset

Static midpointOffset(_context, __namedParameters, padding): ITupV<IVarAD>

Return a point located at the midpoint of a line s1 but offset by padding in its normal direction (for labeling).

Parameters

NameType
_contextContext
__namedParameters[string, any]
paddingIVarAD

Returns

ITupV<IVarAD>

Defined in

contrib/Functions.ts:2365


min

Static min(_context, x, y): IFloatV<IVarAD>

Return the min of the numbers x, y.

Parameters

NameType
_contextContext
xIVarAD
yIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2867


mul

Static mul(_context, m, v): IVectorV<IVarAD>

Multiply a matrix m and a vector v (where v is implicitly treated as a column vector).

Parameters

NameType
_contextContext
mIVarAD[][]
vIVarAD[]

Returns

IVectorV<IVarAD>

Defined in

contrib/Functions.ts:2671


none

Static none(_context): IColorV<any>

Return a paint of none (no paint)

Parameters

NameType
_contextContext

Returns

IColorV<any>

Defined in

contrib/Functions.ts:1765


norm

Static norm(_context, v): IFloatV<IVarAD>

Return the Euclidean norm of the vector v.

Parameters

NameType
_contextContext
vIVarAD[]

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2901


normalize

Static normalize(_context, v): IVectorV<IVarAD>

Return the normalized version of vector v.

Parameters

NameType
_contextContext
vIVarAD[]

Returns

IVectorV<IVarAD>

Defined in

contrib/Functions.ts:2082


normsq

Static normsq(_context, v): IFloatV<IVarAD>

Return the Euclidean norm squared of the vector v.

Parameters

NameType
_contextContext
vIVarAD[]

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2908


orientedSquare

Static orientedSquare(_context, __namedParameters, __namedParameters, intersection, len): IPathDataV<IVarAD>

Given two orthogonal segments that intersect at intersection, and a size len return a path comprised of three points that describe a perpendicular mark at the angle where the segments intersect.

Parameters

NameType
_contextContext
__namedParameters[string, any]
__namedParameters[string, any]
intersectionPt2
lenIVarAD

Returns

IPathDataV<IVarAD>

Defined in

contrib/Functions.ts:2487


pathFromPoints

Static pathFromPoints(_context, pathType, pts): IPathDataV<IVarAD>

Given a list of points pts, returns a PathData that can be used as input to the Path shape's pathData attribute to be drawn on the screen.

Parameters

NameType
_contextContext
pathTypestring
ptsPt2[]

Returns

IPathDataV<IVarAD>

Defined in

contrib/Functions.ts:2092


perpPathFlat

Static perpPathFlat(len, __namedParameters, __namedParameters): [VecAD, VecAD, VecAD]

Given two perpendicular vectors [startR, endR] and [startL, endL], return a path that describes a perpendicular mark between them.

Parameters

NameType
lenIVarAD
__namedParameters[VecAD, VecAD]
__namedParameters[VecAD, VecAD]

Returns

[VecAD, VecAD, VecAD]

Defined in

contrib/Functions.ts:3001


pow

Static pow(_context, x, y): IFloatV<IVarAD>

Return pow(x,y).

Parameters

NameType
_contextContext
xIVarAD
yIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1957


ptOnLine

Static ptOnLine(_context, p1, p2, r): IVectorV<IVarAD>

Find the point that is located at dist r along a line between p1 and p2.

returns: vector representation of the point of intersection

Parameters

NameType
_contextContext
p1IVarAD[]
p2IVarAD[]
rIVarAD

Returns

IVectorV<IVarAD>

Defined in

contrib/Functions.ts:2254


quadraticCurveFromPoints

Static quadraticCurveFromPoints(_context, pathType, pts): IPathDataV<IVarAD>

Given a list of points pts, returns a PathData that can be used as input to the Path shape's pathData attribute to be drawn on the screen.

Parameters

NameType
_contextContext
pathTypestring
ptsPt2[]

Returns

IPathDataV<IVarAD>

Defined in

contrib/Functions.ts:2108


rgba

Static rgba(_context, r, g, b, a): IColorV<IVarAD>

Return a paint color of elements r, g, b, a (red, green, blue, opacity).

Parameters

NameType
_contextContext
rIVarAD
gIVarAD
bIVarAD
aIVarAD

Returns

IColorV<IVarAD>

Defined in

contrib/Functions.ts:1710


rot90

Static rot90(_context, v): Object

Rotate a 2D vector v by 90 degrees counterclockwise.

Parameters

NameType
_contextContext
vIVarAD[]

Returns

Object

NameType
contentsIVarAD[]
tagstring

Defined in

contrib/Functions.ts:2964


rot90v

Static rot90v(__namedParameters): IVarAD[]

Rotate a 2D point [x, y] by 90 degrees clockwise.

Parameters

NameType
__namedParametersIVarAD[]

Returns

IVarAD[]

Defined in

contrib/Functions.ts:3033


rotateBy

Static rotateBy(_context, v, theta): Object

Rotate a 2D vector v by theta degrees counterclockwise.

Parameters

NameType
_contextContext
vIVarAD[]
thetaIVarAD

Returns

Object

NameType
contentsIVarAD[]
tagstring

Defined in

contrib/Functions.ts:2975


round

Static round(_context, x): IFloatV<IVarAD>

Return round(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1967


sampleColor

Static sampleColor(context, alpha, colorType): IColorV<IVarAD>

Sample a random color once, with opacity alpha and colorType colorType ("rgb" or "hsv").

Parameters

NameType
contextContext
alphaIVarAD
colorTypestring

Returns

IColorV<IVarAD>

Defined in

contrib/Functions.ts:2610


selectColor

Static selectColor(_context, color1, color2, level): IColorV<IVarAD>

Parameters

NameType
_contextContext
color1Color<IVarAD>
color2Color<IVarAD>
levelIVarAD

Returns

IColorV<IVarAD>

Defined in

contrib/Functions.ts:1726


setOpacity

Static setOpacity(_context, color, frac): IColorV<IVarAD>

Set the opacity of a color color to frac.

Parameters

NameType
_contextContext
colorColor<IVarAD>
fracIVarAD

Returns

IColorV<IVarAD>

Defined in

contrib/Functions.ts:2644


sign

Static sign(_context, x): IFloatV<IVarAD>

Return sign(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1977


sin

Static sin(_context, x): IFloatV<IVarAD>

Return sin(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1987


sinh

Static sinh(_context, x): IFloatV<IVarAD>

Return sinh(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:1997


sqr

Static sqr(_context, x): IFloatV<IVarAD>

Return the square of the number x.

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2846


sqrt

Static sqrt(_context, x): IFloatV<IVarAD>

Return the square root of the number x. (NOTE: if x < 0, you may get NaNs)

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2853


tan

Static tan(_context, x): IFloatV<IVarAD>

Return tan(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2007


tanh

Static tanh(_context, x): IFloatV<IVarAD>

Return tanh(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2017


tickPlacement

Static tickPlacement(padding, numPts, multiplier?): IVarAD[]

Parameters

NameType
paddingIVarAD
numPtsIVarAD
multiplierIVarAD

Returns

IVarAD[]

Defined in

contrib/Functions.ts:3060


ticksOnLine

Static ticksOnLine(_context, pt1, pt2, spacing, numTicks, tickLength): IPathDataV<IVarAD>

Create equally spaced tick marks centered at the midpoint of a line

Parameters

NameType
_contextContext
pt1IVarAD[]
pt2IVarAD[]
spacingIVarAD
numTicksIVarAD
tickLengthIVarAD

Returns

IPathDataV<IVarAD>

Defined in

contrib/Functions.ts:2454


toDegrees

Static toDegrees(_context, theta): IFloatV<IVarAD>

Convert the angle theta from radians to degrees.

Parameters

NameType
_contextContext
thetaIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2891


toPt

Static toPt(v): Pt2

Parameters

NameType
vVecAD

Returns

Pt2

Defined in

contrib/Functions.ts:2991


toRadians

Static toRadians(_context, theta): IFloatV<IVarAD>

Convert the angle theta from degrees to radians.

Parameters

NameType
_contextContext
thetaIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2881


triangle

Static triangle(_context, __namedParameters, __namedParameters, __namedParameters): IPathDataV<IVarAD>

Given three lines l1, l2, l3 that already form a triangle, return a path that describes the triangle (which can then be filled, etc.).

Parameters

NameType
_contextContext
__namedParametersany
__namedParametersany
__namedParametersany

Returns

IPathDataV<IVarAD>

Defined in

contrib/Functions.ts:2556


trunc

Static trunc(_context, x): IFloatV<IVarAD>

Return trunc(x).

Parameters

NameType
_contextContext
xIVarAD

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2027


unit

Static unit(_context, v): IVectorV<IVarAD>

Return the normalized version of vector v.

Parameters

NameType
_contextContext
vIVarAD[]

Returns

IVectorV<IVarAD>

Defined in

contrib/Functions.ts:2600


unitMark

Static unitMark(_context, __namedParameters, __namedParameters, t, padding, barSize): IPtListV<IVarAD>

Return two points parallel to line s1 using its normal line s2.

Parameters

NameType
_contextContext
__namedParameters[string, any]
__namedParameters[string, any]
tstring
paddingIVarAD
barSizeIVarAD

Returns

IPtListV<IVarAD>

Defined in

contrib/Functions.ts:2143


unitMark2

Static unitMark2(_context, __namedParameters, t, padding, size): IPtListV<IVarAD>

Return two points to "cap off" the line made in unitMark.

Parameters

NameType
_contextContext
__namedParameters[Pt2, Pt2]
tstring
paddingIVarAD
sizeIVarAD

Returns

IPtListV<IVarAD>

Defined in

contrib/Functions.ts:2169


vdist

Static vdist(_context, v, w): IFloatV<IVarAD>

Return the Euclidean distance between the vectors v and w.

Parameters

NameType
_contextContext
vIVarAD[]
wIVarAD[]

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2915


vdistsq

Static vdistsq(_context, v, w): IFloatV<IVarAD>

Return the Euclidean distance squared between the vectors v and w.

Parameters

NameType
_contextContext
vIVarAD[]
wIVarAD[]

Returns

IFloatV<IVarAD>

Defined in

contrib/Functions.ts:2926


vmul

Static vmul(_context, s, v): IVectorV<IVarAD>

Parameters

NameType
_contextContext
sIVarAD
vIVarAD[]

Returns

IVectorV<IVarAD>

Defined in

contrib/Functions.ts:2919


wedge

Static wedge(_context, center, start, end, radius, rotation, largeArc, arcSweep): IPathDataV<IVarAD>

Return series of elements that render a "wedge", which is the same as the arc above except that it's connected to the circle center and filled

returns: Elements that can be passed to Path shape spec to render an SVG arc

Parameters

NameType
_contextContext
centerPt2
startPt2
endPt2
radiusPt2
rotationIVarAD
largeArcIVarAD
arcSweepIVarAD

Returns

IPathDataV<IVarAD>

Defined in

contrib/Functions.ts:2228