intersections
intersections()
Calculates the intersections between multiple paths and creates one anchor per intersection point.
All resulting anchors will be named numerically, starting at 0. i.e., a call intersections("a", ...) will generate the anchors "a.0", "a.1", "a.2" to "a.n", depending of the number of intersections.
You can also use named elements:
You can calculate intersections with hidden elements by using hide.
CeTZ provides the following sorting functions:
- sorting.points-by-distace(points, reference: (0, 0, 0))
- sorting.points-by-angle(points, reference: (0, 0, 0))
intersections("i", {
circle((0, 0))
bezier((0,0), (3,0), (1,-1), (2,1))
line((0,-1), (0,1))
rect((1.5,-1),(2.5,1))
})
for-each-anchor("i", (name) => {
circle("i." + name, radius: .1, fill: blue)
})
circle((0,0), name: "a")
rect((0,0), (1,1), name: "b")
intersections("i", "a", "b")
for-each-anchor("i", (name) => {
circle("i." + name, radius: .1, fill: blue)
})
Name to prepend to the generated anchors. (Not to be confused with other name arguments that allow the use of anchor coordinates.)
Elements and/or element names to calculate intersections with. Elements referred to by name are (unlike elements passed) not drawn by the intersections function!
Number of samples to use for non-linear path segments. A higher sample count can give more precise results but worse performance.
A function of the form (context, array<vector>) -> array<vector> that gets called with the list of intersection points.