diff --git a/src/draw.typ b/src/draw.typ index 9baf614b..59b9f5ef 100644 --- a/src/draw.typ +++ b/src/draw.typ @@ -1,4 +1,4 @@ -#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 +#import "draw/grouping.typ": intersections, group, scope, anchor, copy-anchors, set-ctx, get-ctx, for-each-anchor, on-layer, hide, floating #import "draw/transformations.typ": set-transform, rotate, translate, scale, set-origin, move-to, set-viewport #import "draw/styling.typ": set-style, fill, stroke #import "draw/shapes.typ": circle, circle-through, arc, arc-through, mark, line, grid, content, rect, bezier, bezier-through, catmull, hobby, merge-path diff --git a/src/lib/decorations/brace.typ b/src/lib/decorations/brace.typ index 891986a1..1ff20ac5 100644 --- a/src/lib/decorations/brace.typ +++ b/src/lib/decorations/brace.typ @@ -208,8 +208,6 @@ type(amplitude) in (int, float), message: "amplitude must be a number, got " + repr(amplitude), ) - // we achieve flipping by inverting the amplitude - if flip { amplitude *= -1 } let aspect = style.aspect assert( @@ -264,6 +262,12 @@ set-origin(start) rotate(vector.angle2(start, end)) + // we achieve flipping by inverting the amplitude + if flip { + amplitude *= -1 + content-offset *= -1 + } + let length = vector.dist(start, end) let middle = aspect * length let horizon = amplitude / 2 diff --git a/tests/decorations/ref/1.png b/tests/decorations/ref/1.png index f88cd9fa..16d98483 100644 Binary files a/tests/decorations/ref/1.png and b/tests/decorations/ref/1.png differ diff --git a/tests/decorations/test.typ b/tests/decorations/test.typ index e452518c..e66c781d 100644 --- a/tests/decorations/test.typ +++ b/tests/decorations/test.typ @@ -45,3 +45,20 @@ (amplitude: 3), (amplitude: 4), )) + +// Bug #687 +#test-case(args => { + decorations.flat-brace((-1,-1), (1,1), ..args, name: "brace") + draw.circle("brace.content", radius: 0.1); +}, args: ( + (flip: false), + (flip: true), +)) + +#test-case(args => { + decorations.brace((-1,-1), (1,1), ..args, name: "brace") + draw.circle("brace.content", radius: 0.1); +}, args: ( + (flip: false), + (flip: true), +))