Skip to content

Commit 8f92067

Browse files
Fix flat-brace flipped content anchor (#688)
* Fix flat-brace flipped content anchor fixes #687 * Add test * Fix CI
1 parent 371a2c3 commit 8f92067

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

src/draw.typ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#import "draw/grouping.typ": intersections, group, scope, anchor, copy-anchors, place-anchors, set-ctx, get-ctx, for-each-anchor, on-layer, place-marks, hide, floating
1+
#import "draw/grouping.typ": intersections, group, scope, anchor, copy-anchors, set-ctx, get-ctx, for-each-anchor, on-layer, hide, floating
22
#import "draw/transformations.typ": set-transform, rotate, translate, scale, set-origin, move-to, set-viewport
33
#import "draw/styling.typ": set-style, fill, stroke
44
#import "draw/shapes.typ": circle, circle-through, arc, arc-through, mark, line, grid, content, rect, bezier, bezier-through, catmull, hobby, merge-path

src/lib/decorations/brace.typ

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,6 @@
208208
type(amplitude) in (int, float),
209209
message: "amplitude must be a number, got " + repr(amplitude),
210210
)
211-
// we achieve flipping by inverting the amplitude
212-
if flip { amplitude *= -1 }
213211

214212
let aspect = style.aspect
215213
assert(
@@ -264,6 +262,12 @@
264262
set-origin(start)
265263
rotate(vector.angle2(start, end))
266264

265+
// we achieve flipping by inverting the amplitude
266+
if flip {
267+
amplitude *= -1
268+
content-offset *= -1
269+
}
270+
267271
let length = vector.dist(start, end)
268272
let middle = aspect * length
269273
let horizon = amplitude / 2

tests/decorations/ref/1.png

3.61 KB
Loading

tests/decorations/test.typ

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,20 @@
4545
(amplitude: 3),
4646
(amplitude: 4),
4747
))
48+
49+
// Bug #687
50+
#test-case(args => {
51+
decorations.flat-brace((-1,-1), (1,1), ..args, name: "brace")
52+
draw.circle("brace.content", radius: 0.1);
53+
}, args: (
54+
(flip: false),
55+
(flip: true),
56+
))
57+
58+
#test-case(args => {
59+
decorations.brace((-1,-1), (1,1), ..args, name: "brace")
60+
draw.circle("brace.content", radius: 0.1);
61+
}, args: (
62+
(flip: false),
63+
(flip: true),
64+
))

0 commit comments

Comments
 (0)