(boundary, line)
| 63 | } |
| 64 | |
| 65 | export function _pointsFromSegments(boundary, line) { |
| 66 | const {x = null, y = null} = boundary || {}; |
| 67 | const linePoints = line.points; |
| 68 | const points = []; |
| 69 | line.segments.forEach(({start, end}) => { |
| 70 | end = _findSegmentEnd(start, end, linePoints); |
| 71 | const first = linePoints[start]; |
| 72 | const last = linePoints[end]; |
| 73 | if (y !== null) { |
| 74 | points.push({x: first.x, y}); |
| 75 | points.push({x: last.x, y}); |
| 76 | } else if (x !== null) { |
| 77 | points.push({x, y: first.y}); |
| 78 | points.push({x, y: last.y}); |
| 79 | } |
| 80 | }); |
| 81 | return points; |
| 82 | } |
| 83 | |
| 84 | export function _findSegmentEnd(start, end, points) { |
| 85 | for (;end > start; end--) { |
no test coverage detected