Skip to main content
100%

Finite State Stream

✓ Published0🌍 Public
Mmbostock
Last edited Dec 19, 2012
Created on Dec 19, 2012

This visualization demonstrates how GeoJSON path rendering can be optimized by maintaining a finite state machine that tracks whether the path context is currently inside a line, polygon, or at its first point. Using the `d3.geoPath` context API, the code selectively issues `moveTo`, `lineTo`, `arc`, and `closePath` calls based on the state bits, avoiding redundant drawing operations. The `pointRadius` parameter controls the size of point markers, while `polygonStart` and `polygonEnd` toggle polygon state to manage closed shapes efficiently. This stateful approach minimizes the number of context switches and drawing commands issued to the underlying rendering engine.

AI-generated description

Similar vizzes