| import "../core/noop"; | |
| import "../math/trigonometry"; | |
| function d3_geo_pathContext(context) { | |
| var pointRadius = 4.5; | |
| var stream = { | |
| point: point, | |
| // While inside a line, override point to moveTo then lineTo. | |
| lineStart: function() { stream.point = pointLineStart; }, | |
| lineEnd: lineEnd, | |
| // While inside a polygon, override lineEnd to closePath. | |
| polygonStart: function() { stream.lineEnd = lineEndPolygon; }, | |
| polygonEnd: function() { stream.lineEnd = lineEnd; stream.point = point; }, | |
| pointRadius: function(_) { | |
| pointRadius = _; | |
| return stream; | |
| }, | |
| result: d3_noop | |
| }; | |
| function point(x, y) { | |
| context.moveTo(x, y); | |
| context.arc(x, y, pointRadius, 0, τ); | |
| } | |
| function pointLineStart(x, y) { | |
| context.moveTo(x, y); | |
| stream.point = pointLine; | |
| } | |
| function pointLine(x, y) { | |
| context.lineTo(x, y); | |
| } | |
| function lineEnd() { | |
| stream.point = point; | |
| } | |
| function lineEndPolygon() { | |
| context.closePath(); | |
| } | |
| return stream; | |
| } |