* Create path from points, grouping by truncated x-coordinate * Points need to be in order by x-coordinate for this to work efficiently * @param {CanvasRenderingContext2D|Path2D} ctx - Context * @param {LineElement} line * @param {object} segment * @param {number} segment.start - start index of
(ctx, line, segment, params)
| 69 | * @param {number} params.end - limit segment to points ending at `start` + `count` index |
| 70 | */ |
| 71 | function pathSegment(ctx, line, segment, params) { |
| 72 | const {points, options} = line; |
| 73 | const {count, start, loop, ilen} = pathVars(points, segment, params); |
| 74 | const lineMethod = getLineMethod(options); |
| 75 | // eslint-disable-next-line prefer-const |
| 76 | let {move = true, reverse} = params || {}; |
| 77 | let i, point, prev; |
| 78 | |
| 79 | for (i = 0; i <= ilen; ++i) { |
| 80 | point = points[(start + (reverse ? ilen - i : i)) % count]; |
| 81 | |
| 82 | if (point.skip) { |
| 83 | // If there is a skipped point inside a segment, spanGaps must be true |
| 84 | continue; |
| 85 | } else if (move) { |
| 86 | ctx.moveTo(point.x, point.y); |
| 87 | move = false; |
| 88 | } else { |
| 89 | lineMethod(ctx, prev, point, reverse, options.stepped); |
| 90 | } |
| 91 | |
| 92 | prev = point; |
| 93 | } |
| 94 | |
| 95 | if (loop) { |
| 96 | point = points[(start + (reverse ? ilen : 0)) % count]; |
| 97 | lineMethod(ctx, prev, point, reverse, options.stepped); |
| 98 | } |
| 99 | |
| 100 | return !!loop; |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Create path from points, grouping by truncated x-coordinate |
nothing calls this directly
no test coverage detected