Skip to content

Commit cd79c7f

Browse files
committed
CC: _segments
1 parent d17e9eb commit cd79c7f

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/elements/element.line.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ function getSegment(segment, points, bounds) {
211211
}
212212

213213
export function boundSegment(segment, points, bounds) {
214+
if (!bounds) {
215+
return [segment];
216+
}
217+
214218
const {axis, start: startBound, end: endBound} = bounds;
215219
const count = points.length;
216220
const {compare, between, normalize} = axisFn(axis);
@@ -249,12 +253,10 @@ export function boundSegment(segment, points, bounds) {
249253
}
250254

251255
export function boundSegments(line, bounds) {
252-
const segments = line.segments;
253-
const points = line.points;
254256
const result = [];
255-
let i, ilen, sub;
256-
for (i = 0, ilen = segments.length; i < ilen; ++i) {
257-
sub = boundSegment(segments[i], points, bounds);
257+
258+
for (let segment of line.segments) {
259+
let sub = boundSegment(segment, line.points, bounds);
258260
if (sub.length) {
259261
result.push(...sub);
260262
}

src/plugins/plugin.filler.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,10 @@ function _clip(ctx, target, clipY) {
242242
}
243243

244244
const TAU = Math.PI * 2;
245-
function getBounds(axis, first, last) {
245+
function getBounds(axis, first, last, loop) {
246+
if (loop) {
247+
return;
248+
}
246249
let start = first[axis];
247250
let end = last[axis];
248251

@@ -259,21 +262,20 @@ function _segments(line, target, axis) {
259262
const parts = [];
260263

261264
for (let segment of line.segments) {
262-
const bounds = getBounds(axis, points[segment.start]._view, points[segment.end]._view);
265+
const bounds = getBounds(axis, points[segment.start]._view, points[segment.end]._view, segment.loop);
263266

264267
if (!target.segments) {
265268
// Special case for boundary not supporting `segments` (simpleArc)
266269
// Bounds are provided as `target` for partial circle, or undefined for full circle
267-
parts.push({source: segment, target: !segment.loop && bounds});
270+
parts.push({source: segment, target: bounds});
268271
continue;
269272
}
270273

271274
// Get all segments from `target` that intersect the bounds of current segment of `line`
272-
const subs = segment.loop ? target.segments : boundSegments(target, bounds);
275+
const subs = boundSegments(target, bounds);
273276

274277
for (let sub of subs) {
275-
const fillSources = sub.loop ? [segment] :
276-
boundSegment(segment, points, getBounds(axis, tpoints[sub.start]._view, tpoints[sub.end]._view));
278+
const fillSources = boundSegment(segment, points, getBounds(axis, tpoints[sub.start]._view, tpoints[sub.end]._view, sub.loop));
277279

278280
for (let source of fillSources) {
279281
parts.push({source, target: sub});

0 commit comments

Comments
 (0)