A simple representation of the Hilbert curve, using d3-hilbert layout. Use the slider to modify the curve order (number of iterations). On mouse hover, XY coordinates are reversely converted to curve distance. Zoom/pan the canvas using mouse-wheel/drag events.
See also Morton (Z-order) curve.
https://code.jquery.com/jquery-3.1.0.min.js
https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.6/d3.min.js
https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/9.1.3/bootstrap-slider.min.js
https://unpkg.com/d3-hilbert