| 287 | let i = start; |
| 288 | |
| 289 | function addStyle(s, e, l, st) { |
| 290 | const dir = spanGaps ? -1 : 1; |
| 291 | if (s === e) { |
| 292 | return; |
| 293 | } |
| 294 | // Style can not start/end on a skipped point, adjust indices accordingly |
| 295 | s += count; |
| 296 | while (points[s % count].skip) { |
| 297 | s -= dir; |
| 298 | } |
| 299 | while (points[e % count].skip) { |
| 300 | e += dir; |
| 301 | } |
| 302 | if (s % count !== e % count) { |
| 303 | result.push({start: s % count, end: e % count, loop: l, style: st}); |
| 304 | prevStyle = st; |
| 305 | start = e % count; |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | for (const segment of segments) { |
| 310 | start = spanGaps ? start : segment.start; |