
The discussion in #5976 is whether `Path.join()` should use a line segment to close any gaps in the path caused by move operations, or by differences in the end and start points of paths being joined. The answer is yes, that is the intended behaviour, but people who read _join_ might expect differently. So I have made a few changes to clarify this: - The new `Path.combine()` method combines multiple path instances into a single instance without making any changes to the drawing operations - Since `Path.combine()` is variadic, I have also updated `Path.join()` to be variadic too, since that is more consistent. - The old way of calling `Path.join(path, bool)` is deprecated and will log a warning. Calling `Path.join()` this way will be removed in v4. - Related to this change is how `Path.length()` should behave when there are gaps in the path. Currently, it skips those. So I've added a parameter that when set to `true` will include them. - Added documentation for `Path.combine()` - Updated documentation for `Path.join()` - Updated documentation for `Path.length()`
1.2 KiB
title |
---|
Path.combine() |
The Path.combines()
method combines this path with one or more other paths
into a single Path instance.
Any gaps in the path (caused by move operations) will be left as-is, rather
than joined with a line. If that's not what you want, you should use
Path.join()
instead.
Signature
Path path.combine(path other)
Examples
```js ({ Point, points, Path, paths, part }) => {points.A1 = new Point(0, 0) points.A2 = new Point(60, 0) points.B1 = new Point(0, 10) points.B2 = new Point(60, 10) points.C1 = new Point(0, 20) points.C2 = new Point(60, 20)
paths.path1 = new Path() .move(points.A1) .line(points.A2) .setClass("various")
paths.path2 = new Path() .move(points.B1) .line(points.B2) .setClass("note")
paths.path3 = new Path() .move(points.C1) .line(points.C2) .setClass("canvas")
paths.combo = paths.path1 .combine(paths.path2, paths.path3) .setClass("lining dotted")
return part }
</Example>
## Notes
`Path.combine()` method is _variadic_, so you can pass multiple paths to join