Skip to content

Commit

Permalink
Fix line-content intersection (#677)
Browse files Browse the repository at this point in the history
* Fix #621

* Update ref images
  • Loading branch information
johannes-wolf authored Aug 11, 2024
1 parent c52b987 commit 035a667
Show file tree
Hide file tree
Showing 36 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package called `cetz-plot`.
- The center anchor of `content()` with two coordinates got fixed when using
negative cordinates.
- Element names are now checked to not contain a "." character.
- Fixed intersection bug for content with `anchor:` set.

## Draw
- Added `floating` function for drawing elements without affecting bounding boxes.
Expand Down
2 changes: 1 addition & 1 deletion src/draw/shapes.typ
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@
let (ta, tb) = util.apply-transform(ctx.transform, a, b)

let pts = ()
for drawable in elem.at("drawables", default: ()) {
for drawable in elem.at("drawables", default: ()).filter(d => d.type == "path") {
pts += intersection.line-path(ta, tb, drawable)
}
return if pts == () {
Expand Down
Binary file modified tests/anchor/copy-anchors/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/arc/last-pos/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/bezier/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/catmul/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/circle-through/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/content/intersection/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions tests/content/intersection/test.typ
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,31 @@
})
})
})

#test-case({
import draw: *

draw.content(name: "test1", frame: "rect", (0,0))[Test 1]
draw.content(name: "test2", frame: "rect", (-1,-1))[Test 2]
draw.line("test1", "test2")
})

#test-case({
let thide = hide
import draw: *

draw.content(name: "test1", (0,0))[Test 1]
draw.content((-1,-1))[#box(stroke: 1pt + red, thide[Test 2])]
draw.content(name: "test2", frame: "rect", anchor: "north-east", (-1,-1))[Test 2]
draw.line("test1", "test2")
})

#test-case({
let thide = hide
import draw: *

draw.content(name: "test1", (0,0))[Test 1]
draw.content((-1,-1))[#box(stroke: 1pt + red, thide[Test 2])]
draw.content(name: "test2", frame: "rect", anchor: "south", (-1,-1))[Test 2]
draw.line("test1", "test2")
})
Binary file modified tests/content/span/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/cube/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/decorations/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/empty/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/grid/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/group/empty/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/group/none/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/group/padding/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/hobby/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/line/element-element/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/local-anchor/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/mark/anchor/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/mark/offset/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/mark/pos/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/mark/shape-transform/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/mark/single/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/mark/z-axis/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/merge/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/primitives/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/rect/ref/1.png
Binary file modified tests/relative-no-update/ref/1.png
Binary file modified tests/ring/ref/1.png
Binary file modified tests/rotation/around/ref/1.png
Binary file modified tests/rotation/ref/1.png
Binary file modified tests/set-get-ctx/ref/1.png
Binary file modified tests/style/ref/1.png
Binary file modified tests/transform/precission/ref/1.png

0 comments on commit 035a667

Please sign in to comment.