PathContext
Defined in: core/path-context.ts:10
PathContext is the seam of d3gl: the subset of CanvasRenderingContext2D’s path API that d3 path-emitting generators (d3-geo geoPath, d3-shape, d3-chord, d3-hierarchy links) actually call. Implement this once per backend and any of those generators can render to that backend unchanged.
The signatures intentionally match CanvasRenderingContext2D so a real 2D context satisfies this interface structurally.
Methods
Section titled “Methods”arc(
x,y,radius,startAngle,endAngle,counterclockwise?):void
Defined in: core/path-context.ts:36
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
Returns
Section titled “Returns”void
arcTo()
Section titled “arcTo()”arcTo(
x1,y1,x2,y2,radius):void
Defined in: core/path-context.ts:44
Parameters
Section titled “Parameters”number
number
number
number
radius
Section titled “radius”number
Returns
Section titled “Returns”void
beginPath()
Section titled “beginPath()”beginPath():
void
Defined in: core/path-context.ts:11
Returns
Section titled “Returns”void
bezierCurveTo()
Section titled “bezierCurveTo()”bezierCurveTo(
cp1x,cp1y,cp2x,cp2y,x,y):void
Defined in: core/path-context.ts:28
Parameters
Section titled “Parameters”number
number
number
number
number
number
Returns
Section titled “Returns”void
closePath()
Section titled “closePath()”closePath():
void
Defined in: core/path-context.ts:46
Returns
Section titled “Returns”void
lineTo()
Section titled “lineTo()”lineTo(
x,y):void
Defined in: core/path-context.ts:26
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”void
moveTo()
Section titled “moveTo()”moveTo(
x,y):void
Defined in: core/path-context.ts:25
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”void
quadraticCurveTo()
Section titled “quadraticCurveTo()”quadraticCurveTo(
cpx,cpy,x,y):void
Defined in: core/path-context.ts:27
Parameters
Section titled “Parameters”number
number
number
number
Returns
Section titled “Returns”void
rect()
Section titled “rect()”rect(
x,y,w,h):void
Defined in: core/path-context.ts:45
Parameters
Section titled “Parameters”number
number
number
number
Returns
Section titled “Returns”void
translate()
Section titled “translate()”translate(
dx,dy):void
Defined in: core/path-context.ts:24
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