Skip to content

Commit 9a55ad5

Browse files
Fix Debug Frames & Merge Path (#917)
* tree: Fix transformation and support named nodes - Fixes transformations on the tree - Support named elements in tree nodes * tree: Fix transformation + node anchors * debug: Fix debug paths * merge-path: Fix Path Closing * merge-path: Update tests * changelog: Update changelog
1 parent 152e079 commit 9a55ad5

File tree

5 files changed

+26
-10
lines changed

5 files changed

+26
-10
lines changed

CHANGES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
- **BREAKING** The `tree` callback for drawing nodes does not pass the parent nodes name anymore (new signature is `(node) => elements`)
66
- **BREAKING** The `parent-position` argument of `tree` got removed
77
- Tree nodes now support anchors: custom anchors from the `draw-node` callback
8-
are accessible.
8+
are accessible (#904)
99
- `styles.resolve` now supports nested roots by passing an array (#914)
10+
- Fixed debug frames (#917)
11+
- Fixed a regression with `merge-path`'s `close:` argument (#910)
1012

1113
# 0.4.0
1214
- Fixed a bug where passing a length as radius to a polygon resulted in an error

src/draw/shapes.typ

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,6 @@
17641764
segments.push(("l", next-origin))
17651765
segments += next-segments
17661766

1767-
// TODO: Close is not working as expected here
17681767
subpaths.last() = (origin, closed or close, segments)
17691768
subpaths += drawables.slice(1).filter(d => {
17701769
d.type == "path"
@@ -1777,6 +1776,13 @@
17771776
}
17781777
}
17791778

1779+
// Close paths
1780+
if close {
1781+
subpaths = subpaths.map(((origin, closed, elems)) => {
1782+
(origin, close or closed, elems)
1783+
})
1784+
}
1785+
17801786
let style = styles.resolve(ctx.style, merge: style)
17811787
let drawables = drawable.path(fill: style.fill, fill-rule: style.fill-rule, stroke: style.stroke, subpaths)
17821788

src/process.typ

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@
5151
}
5252

5353
if ctx.debug and bounds != none {
54-
element.drawables.push(drawable.path(
55-
((bounds.low, true, (
56-
("l", (bounds.high.at(0), bounds.low.at(1), 0)),
57-
("l", bounds.high),
58-
("l", (bounds.low.at(0), bounds.high.at(1), 0)))),),
59-
stroke: red,
60-
close: true
61-
))
54+
element.drawables.push(drawable.line-strip(
55+
(bounds.low,
56+
(bounds.high.at(0), bounds.low.at(1), 0.0),
57+
bounds.high,
58+
(bounds.low.at(0), bounds.high.at(1), 0.0)
59+
),
60+
close: true,
61+
stroke: red))
6262
}
6363

6464
return (

tests/merge/ref/1.png

432 Bytes
Loading

tests/merge/test.typ

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,11 @@
4747
circle((name: "p", anchor: 1% * i), radius: .1, fill: white)
4848
}
4949
})
50+
51+
#test-case({
52+
import draw: *
53+
54+
merge-path(close: true, fill: red, {
55+
line((0,0), (1,0), (1,1))
56+
})
57+
})

0 commit comments

Comments
 (0)