From 74e2a3f579727911c3bb28b506e739c0b24ef8a7 Mon Sep 17 00:00:00 2001 From: johannes-wolf Date: Tue, 28 Nov 2023 22:36:11 +0100 Subject: [PATCH] arc: Set previous point to arc end --- src/draw/shapes.typ | 5 ++++- tests/arc/last-pos/ref.png | Bin 0 -> 15277 bytes tests/arc/last-pos/test.typ | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/arc/last-pos/ref.png create mode 100644 tests/arc/last-pos/test.typ diff --git a/src/draw/shapes.typ b/src/draw/shapes.typ index e1521705f..979bebab6 100644 --- a/src/draw/shapes.typ +++ b/src/draw/shapes.typ @@ -311,7 +311,10 @@ z ) - // center is calculated based on observations of tikz's circular sector and semi circle shapes. + // Set the last position to arc-end + 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/tests/arc/last-pos/ref.png b/tests/arc/last-pos/ref.png new file mode 100644 index 0000000000000000000000000000000000000000..7427cfee865232e9c71f1add5220c451f83850de GIT binary patch literal 15277 zcmeI3eN>b6-^VZHR!mcRu=thA`c=Q1o^-$R=Tkha?lSHU<$AbjDY|tZQ!27)MBCWd zrBPy1tcPDMMOft_3WAmV6lo6^h>C?c%U~k14bUwZu))~#uIswL-|u821sQ+b=iKMq zaE?a~9KP4}{d_+U@6YS=-TTk1O`SLA_Bj}a&3p1cAAb(RqCN%xYG%&@Kk56y$HB0~ zx1N0b(f<-g4Va=ny8Fpb?tb#7!iv4B)W;v+vSrH)>EKHMzuc$(H@@D2OLI8zDO7#VYPxIzjV$^HEOT&76(SJ26x@HTO_HrfC!FpL81KGwsg&eir!e zqYO@TZFO6~*>Iz(=NQqJr8w6mT%sOnn-yEC6WS#wvKAZ7c$qwRou`7|T~W#Xw_tUR zJIuQmU!rBB~Xf1*$M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Y5-N^&0?jiEb$802uiu zRH=o%a_OrmiAON0sxz|rB^S3!2j!wO`SHgfwoa$B2gVHQ;A}C5h^R3BWY)(Cov1sTa+~r2McVGuqK`*{LYTHov8mLrjCYKhN)>kCo^n$BbZ^HwOU>fMFV$G~)kPQfO z(}1jkTU)3kz>tn!3=p=C+TrdwKn2{w(F<8uPqDr>`ku!EzcQ|ex5k_-BT`hWfm*?~ zwHyEtyZ-fBH| zE*EPjk6Li#tptVhqlMo77~|~mr&&^eo-tqVt!#3vZxR3=E#;s)m~{K)i3TL1a6x^Z ztiYC+g$0L4yxz~oA=LqwUmK%zaAX!Vf3cC(L91n>yKYcYL_=)v$P|7hwa)EgY72C^ zCqI<9GBh)<1*_Fqe^FoGG}xw zo-DNTFTUq%ROYh+xs%LC!dEjX%TJ>f5VLvDZfn^j)V7K38h*5V&{WRtzESP8YT~c9 zQ1B990qdre{!K^v@WV3dAk&g1H5HhELuKI6{TEJVzi4aV=iLZUc5p{>(KSYOU_#hl za=VfQ=f|I41PDLV&jo<~&Gz<$dY&Y9!%z8}4h`#-_HMuz8z-cTpk^unMK!R6x3jWc zcj|O$TepG26j#&STVK6cML7wT4B~5>p3&g|pC)1`s&Nuzx#Q&$C=nUL7`}U74^5%wK@G)HM O$u(;qul|ph-uWL9xK7vr literal 0 HcmV?d00001 diff --git a/tests/arc/last-pos/test.typ b/tests/arc/last-pos/test.typ new file mode 100644 index 000000000..c1be7d4ef --- /dev/null +++ b/tests/arc/last-pos/test.typ @@ -0,0 +1,16 @@ +#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) +}))