SvgPathContext
Defined in: svg/svg-context.ts:20
A PathContext that accumulates an SVG path d string. Used for publication
vector export: re-run a d3 generator (geoPath, d3-shape, …) into this context
and read toPath(). Curves map to native C/Q commands; arcs are flattened to
line segments (correct geometry; geo export is polygons/lines, so this is rare).
tolerance controls only arc flattening (arc and arcTo) and is independent of a
PathRecorder’s tolerance — pass the same value if you need the SVG arc density to match
the GPU. Both default to DEFAULT_CURVE_TOLERANCE, the one source of truth the
engines’ curveTolerance option also feeds (#45).
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SvgPathContext(
tolerance?):SvgPathContext
Defined in: svg/svg-context.ts:32
Parameters
Section titled “Parameters”tolerance?
Section titled “tolerance?”number = DEFAULT_CURVE_TOLERANCE
Returns
Section titled “Returns”SvgPathContext
Properties
Section titled “Properties”tolerance
Section titled “tolerance”tolerance:
number=DEFAULT_CURVE_TOLERANCE
Defined in: svg/svg-context.ts:32
Methods
Section titled “Methods”arc(
x,y,radius,startAngle,endAngle,counterclockwise?):void
Defined in: svg/svg-context.ts:79
Parameters
Section titled “Parameters”number
number
radius
Section titled “radius”number
startAngle
Section titled “startAngle”number
endAngle
Section titled “endAngle”number
counterclockwise?
Section titled “counterclockwise?”boolean = false
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”arcTo()
Section titled “arcTo()”arcTo(
x1,y1,x2,y2,radius):void
Defined in: svg/svg-context.ts:91
Tangent arc with Canvas-2D semantics — the same flattenArcTo the GPU recorder uses, so a rounded corner is the identical polyline on every backend (#86).
Parameters
Section titled “Parameters”number
number
number
number
radius
Section titled “radius”number
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”beginPath()
Section titled “beginPath()”beginPath():
void
Defined in: svg/svg-context.ts:38
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”bezierCurveTo()
Section titled “bezierCurveTo()”bezierCurveTo(
cp1x,cp1y,cp2x,cp2y,x,y):void
Defined in: svg/svg-context.ts:74
Parameters
Section titled “Parameters”number
number
number
number
number
number
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”closePath()
Section titled “closePath()”closePath():
void
Defined in: svg/svg-context.ts:109
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”lineTo()
Section titled “lineTo()”lineTo(
x,y):void
Defined in: svg/svg-context.ts:60
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”moveTo()
Section titled “moveTo()”moveTo(
x,y):void
Defined in: svg/svg-context.ts:51
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”quadraticCurveTo()
Section titled “quadraticCurveTo()”quadraticCurveTo(
cpx,cpy,x,y):void
Defined in: svg/svg-context.ts:69
Parameters
Section titled “Parameters”number
number
number
number
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”rect()
Section titled “rect()”rect(
x,y,w,h):void
Defined in: svg/svg-context.ts:102
Parameters
Section titled “Parameters”number
number
number
number
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”toPath()
Section titled “toPath()”toPath():
string
Defined in: svg/svg-context.ts:34
Returns
Section titled “Returns”string
translate()
Section titled “translate()”translate(
dx,dy):void
Defined in: svg/svg-context.ts:43
Shift all subsequent path coordinates by (dx, dy), accumulating like
CanvasRenderingContext2D.translate. The canonical d3 idiom for placing an
origin-centred generator (radial trees, chords, …) at an offset: call
translate(cx, cy) once, then run the generator into this context unchanged.
This is the only transform in the seam — no rotate/scale/save/restore. Radial generators bake angle into their coordinates, so a translation is all they need; a richer transform stack would complicate every backend for no current consumer. The offset is part of context state (not reset by beginPath) and, in retained backends, lives only for the single drawable the callback is recording.
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”void