Skip to content

SvgPathContext

Defined in: svg/svg-context.ts:18

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 and is independent of a PathRecorder’s tolerance — pass the same value if you need the SVG arc density to match the GPU.

new SvgPathContext(tolerance?): SvgPathContext

Defined in: svg/svg-context.ts:25

number = 0.25

SvgPathContext

tolerance: number = 0.25

Defined in: svg/svg-context.ts:25

arc(x, y, radius, startAngle, endAngle, counterclockwise?): void

Defined in: svg/svg-context.ts:56

number

number

number

number

number

boolean = false

void

PathContext.arc


arcTo(x1, y1, x2, y2, _radius): void

Defined in: svg/svg-context.ts:66

number

number

number

number

number

void

PathContext.arcTo


beginPath(): void

Defined in: svg/svg-context.ts:31

void

PathContext.beginPath


bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y): void

Defined in: svg/svg-context.ts:52

number

number

number

number

number

number

void

PathContext.bezierCurveTo


closePath(): void

Defined in: svg/svg-context.ts:78

void

PathContext.closePath


lineTo(x, y): void

Defined in: svg/svg-context.ts:44

number

number

void

PathContext.lineTo


moveTo(x, y): void

Defined in: svg/svg-context.ts:40

number

number

void

PathContext.moveTo


quadraticCurveTo(cpx, cpy, x, y): void

Defined in: svg/svg-context.ts:48

number

number

number

number

void

PathContext.quadraticCurveTo


rect(x, y, w, h): void

Defined in: svg/svg-context.ts:72

number

number

number

number

void

PathContext.rect


toPath(): string

Defined in: svg/svg-context.ts:27

string


translate(dx, dy): void

Defined in: svg/svg-context.ts:35

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.

number

number

void

PathContext.translate