|
| 1 | +function d3_geo_streamBuffer() { |
| 2 | + this._buffer = []; |
| 3 | + this._point = d3_geo_pathCircle(4.5); |
| 4 | +} |
| 5 | + |
| 6 | +var d3_geo_streamBufferPrototype = { |
| 7 | + point: d3_geo_streamBufferPoint, |
| 8 | + |
| 9 | + // While inside a line, override point to moveTo then lineTo. |
| 10 | + lineStart: function() { this.point = d3_geo_streamBufferPointLineStart; }, |
| 11 | + lineEnd: d3_geo_streamBufferLineEnd, |
| 12 | + |
| 13 | + // While inside a polygon, override lineEnd to closePath. |
| 14 | + polygonStart: function() { this.lineEnd = d3_geo_streamBufferLineEndPolygon; }, |
| 15 | + polygonEnd: function() { this.lineEnd = d3_geo_streamBufferLineEnd; }, |
| 16 | + |
| 17 | + toString: function() { |
| 18 | + var s = this._buffer.join(""); |
| 19 | + this._buffer = []; |
| 20 | + return s; |
| 21 | + } |
| 22 | +} |
| 23 | + |
| 24 | +function d3_geo_streamBufferPoint(x, y) { |
| 25 | + this._buffer.push("M", x, ",", y, this._point); |
| 26 | +} |
| 27 | + |
| 28 | +function d3_geo_streamBufferPointLineStart(x, y) { |
| 29 | + this._buffer.push("M", x, ",", y); |
| 30 | + this.point = d3_geo_streamBufferPointLine; |
| 31 | +} |
| 32 | + |
| 33 | +function d3_geo_streamBufferPointLine(x, y) { |
| 34 | + this._buffer.push("L", x, ",", y); |
| 35 | +} |
| 36 | + |
| 37 | +function d3_geo_streamBufferLineEnd() { |
| 38 | + this.point = d3_geo_streamBufferPoint; |
| 39 | +} |
| 40 | + |
| 41 | +function d3_geo_streamBufferLineEndPolygon() { |
| 42 | + this._buffer.push("Z"); |
| 43 | +} |
0 commit comments