diff --git a/manual.pdf b/manual.pdf index fcf1dfac..c1f771a2 100644 Binary files a/manual.pdf and b/manual.pdf differ diff --git a/src/draw/shapes.typ b/src/draw/shapes.typ index 1a10d817..aeead32d 100644 --- a/src/draw/shapes.typ +++ b/src/draw/shapes.typ @@ -215,6 +215,8 @@ /// == Keys /// #show-parameter-block("radius", ("number", "array"), [The radius of the arc. An elliptical arc can be created by passing a tuple of numbers where the first element is the x radius and the second element is the y radius.], default: 1) /// #show-parameter-block("mode", ("string",), [The options are: "OPEN" no additional lines are drawn so just the arc is shown; "CLOSE" a line is drawn from the start to the end of the arc creating a circular segment; "PIE" lines are drawn from the start and end of the arc to the origin creating a circular sector.], default: "OPEN") +/// #show-parameter-block("update-position", ("bool",), [Update the current canvas position to the arc's end point (anchor `"arc-end"`). +/// This overrides the default of `true`, that allows chaining of (arc) elements.], default: true) /// /// = Anchors /// Supports compass anchors when `mode` is "PIE" @@ -311,7 +313,12 @@ z ) - // center is calculated based on observations of tikz's circular sector and semi circle shapes. + // Set the last position to arc-end + if style.update-position { + ctx.prev.pt = arc-end + } + + // Center is calculated based on observations of tikz's circular sector and semi circle shapes. let center = if style.mode != "CLOSE" { // A circular sector's center anchor is placed half way between the sector-center and arc-center when the angle is 180deg. At 60deg it is placed 1/3 of the way between, this is mirrored at 300deg. vector.lerp( diff --git a/src/styles.typ b/src/styles.typ index bbf7b840..03a83f0f 100644 --- a/src/styles.typ +++ b/src/styles.typ @@ -89,6 +89,7 @@ // - "PIE" mode: "OPEN", mark: _default-mark, + update-position: true, ), content: ( // Allowed values: diff --git a/tests/arc/last-pos/ref.png b/tests/arc/last-pos/ref.png new file mode 100644 index 00000000..c3dd34ff Binary files /dev/null and b/tests/arc/last-pos/ref.png differ diff --git a/tests/arc/last-pos/test.typ b/tests/arc/last-pos/test.typ new file mode 100644 index 00000000..8701648d --- /dev/null +++ b/tests/arc/last-pos/test.typ @@ -0,0 +1,23 @@ +#set page(width: auto, height: auto) +#import "/src/lib.typ": * + +#box(stroke: 2pt + red, canvas({ + import draw: * + + arc((0,0), start: 0deg, stop: 180deg) + circle((), radius: .1, fill: blue) +})) + +#box(stroke: 2pt + red, canvas({ + import draw: * + + arc((0,0), start: 180deg, stop: 0deg) + circle((), radius: .1, fill: blue) +})) + +#box(stroke: 2pt + red, canvas({ + import draw: * + + arc((0,0), start: 180deg, stop: 0deg, update-position: false) + circle((), radius: .1, fill: blue) +}))