Skip to content

Commit 035a667

Browse files
Fix line-content intersection (#677)
* Fix #621 * Update ref images
1 parent c52b987 commit 035a667

File tree

36 files changed

+30
-1
lines changed

36 files changed

+30
-1
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package called `cetz-plot`.
2020
- The center anchor of `content()` with two coordinates got fixed when using
2121
negative cordinates.
2222
- Element names are now checked to not contain a "." character.
23+
- Fixed intersection bug for content with `anchor:` set.
2324

2425
## Draw
2526
- Added `floating` function for drawing elements without affecting bounding boxes.

src/draw/shapes.typ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@
515515
let (ta, tb) = util.apply-transform(ctx.transform, a, b)
516516

517517
let pts = ()
518-
for drawable in elem.at("drawables", default: ()) {
518+
for drawable in elem.at("drawables", default: ()).filter(d => d.type == "path") {
519519
pts += intersection.line-path(ta, tb, drawable)
520520
}
521521
return if pts == () {

tests/anchor/copy-anchors/ref/1.png

29 Bytes
Loading

tests/arc/last-pos/ref/1.png

-20 Bytes
Loading

tests/bezier/ref/1.png

-8 Bytes
Loading

tests/catmul/ref/1.png

-29 Bytes
Loading

tests/circle-through/ref/1.png

1 Byte
Loading

tests/content/intersection/ref/1.png

8.8 KB
Loading

tests/content/intersection/test.typ

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,31 @@
1919
})
2020
})
2121
})
22+
23+
#test-case({
24+
import draw: *
25+
26+
draw.content(name: "test1", frame: "rect", (0,0))[Test 1]
27+
draw.content(name: "test2", frame: "rect", (-1,-1))[Test 2]
28+
draw.line("test1", "test2")
29+
})
30+
31+
#test-case({
32+
let thide = hide
33+
import draw: *
34+
35+
draw.content(name: "test1", (0,0))[Test 1]
36+
draw.content((-1,-1))[#box(stroke: 1pt + red, thide[Test 2])]
37+
draw.content(name: "test2", frame: "rect", anchor: "north-east", (-1,-1))[Test 2]
38+
draw.line("test1", "test2")
39+
})
40+
41+
#test-case({
42+
let thide = hide
43+
import draw: *
44+
45+
draw.content(name: "test1", (0,0))[Test 1]
46+
draw.content((-1,-1))[#box(stroke: 1pt + red, thide[Test 2])]
47+
draw.content(name: "test2", frame: "rect", anchor: "south", (-1,-1))[Test 2]
48+
draw.line("test1", "test2")
49+
})

tests/content/span/ref/1.png

-44 Bytes
Loading

tests/cube/ref/1.png

-11 Bytes
Loading

tests/decorations/ref/1.png

-70 Bytes
Loading

tests/empty/ref/1.png

-724 Bytes
Loading

tests/grid/ref/1.png

0 Bytes
Loading

tests/group/empty/ref/1.png

-724 Bytes
Loading

tests/group/none/ref/1.png

-11 Bytes
Loading

tests/group/padding/ref/1.png

13 Bytes
Loading

tests/hobby/ref/1.png

-92 Bytes
Loading

tests/line/element-element/ref/1.png

-22 Bytes
Loading

tests/local-anchor/ref/1.png

-10 Bytes
Loading

tests/mark/anchor/ref/1.png

-27 Bytes
Loading

tests/mark/offset/ref/1.png

-8 Bytes
Loading

tests/mark/pos/ref/1.png

-7 Bytes
Loading

tests/mark/shape-transform/ref/1.png

-77 Bytes
Loading

tests/mark/single/ref/1.png

-8 Bytes
Loading

tests/mark/z-axis/ref/1.png

-2 Bytes
Loading

tests/merge/ref/1.png

-26 Bytes
Loading

tests/primitives/ref/1.png

-9 Bytes
Loading

tests/rect/ref/1.png

-6 Bytes
Loading

tests/relative-no-update/ref/1.png

-30 Bytes
Loading

tests/ring/ref/1.png

-23 Bytes
Loading

tests/rotation/around/ref/1.png

-153 Bytes
Loading

tests/rotation/ref/1.png

-30 Bytes
Loading

tests/set-get-ctx/ref/1.png

-23 Bytes
Loading

tests/style/ref/1.png

-10 Bytes
Loading

tests/transform/precission/ref/1.png

-102 Bytes
Loading

0 commit comments

Comments
 (0)