@@ -3,7 +3,16 @@ import { arc } from "@/common/geometry"
33import { getEdgeMidpoints } from "./geometry"
44
55// Create arc path with exact start/end points and push to paths array
6- function pushArcPath ( paths , radius , startAngle , endAngle , cx , cy , startPt , endPt ) {
6+ function pushArcPath (
7+ paths ,
8+ radius ,
9+ startAngle ,
10+ endAngle ,
11+ cx ,
12+ cy ,
13+ startPt ,
14+ endPt ,
15+ ) {
716 const arcPath = arc ( radius , startAngle , endAngle , cx , cy )
817
918 arcPath [ 0 ] = startPt . clone ( )
@@ -27,35 +36,99 @@ function drawStrokedArcTile(bounds, orientation, strokeWidth, tileBorder) {
2736 const { left, right, top, bottom } = bounds
2837 const cx = bounds . cx ?? ( left + right ) / 2
2938 const cy = bounds . cy ?? ( top + bottom ) / 2
30- const baseRadius = ( bounds . size ?? ( right - left ) ) / 2
39+ const baseRadius = ( bounds . size ?? right - left ) / 2
3140 const halfStroke = strokeWidth / 2
3241 const innerRadius = baseRadius - halfStroke
3342 const outerRadius = baseRadius + halfStroke
3443
3544 if ( orientation === 0 ) {
3645 // Top-left corner arcs
37- pushArcPath ( paths , innerRadius , Math . PI / 2 , 0 , left , top ,
38- new Victor ( left , cy - halfStroke ) , new Victor ( cx - halfStroke , top ) )
39- pushArcPath ( paths , outerRadius , Math . PI / 2 , 0 , left , top ,
40- new Victor ( left , cy + halfStroke ) , new Victor ( cx + halfStroke , top ) )
46+ pushArcPath (
47+ paths ,
48+ innerRadius ,
49+ Math . PI / 2 ,
50+ 0 ,
51+ left ,
52+ top ,
53+ new Victor ( left , cy - halfStroke ) ,
54+ new Victor ( cx - halfStroke , top ) ,
55+ )
56+ pushArcPath (
57+ paths ,
58+ outerRadius ,
59+ Math . PI / 2 ,
60+ 0 ,
61+ left ,
62+ top ,
63+ new Victor ( left , cy + halfStroke ) ,
64+ new Victor ( cx + halfStroke , top ) ,
65+ )
4166
4267 // Bottom-right corner arcs
43- pushArcPath ( paths , innerRadius , - Math . PI / 2 , - Math . PI , right , bottom ,
44- new Victor ( right , cy + halfStroke ) , new Victor ( cx + halfStroke , bottom ) )
45- pushArcPath ( paths , outerRadius , - Math . PI / 2 , - Math . PI , right , bottom ,
46- new Victor ( right , cy - halfStroke ) , new Victor ( cx - halfStroke , bottom ) )
68+ pushArcPath (
69+ paths ,
70+ innerRadius ,
71+ - Math . PI / 2 ,
72+ - Math . PI ,
73+ right ,
74+ bottom ,
75+ new Victor ( right , cy + halfStroke ) ,
76+ new Victor ( cx + halfStroke , bottom ) ,
77+ )
78+ pushArcPath (
79+ paths ,
80+ outerRadius ,
81+ - Math . PI / 2 ,
82+ - Math . PI ,
83+ right ,
84+ bottom ,
85+ new Victor ( right , cy - halfStroke ) ,
86+ new Victor ( cx - halfStroke , bottom ) ,
87+ )
4788 } else {
4889 // Top-right corner arcs
49- pushArcPath ( paths , innerRadius , Math . PI , Math . PI / 2 , right , top ,
50- new Victor ( cx + halfStroke , top ) , new Victor ( right , cy - halfStroke ) )
51- pushArcPath ( paths , outerRadius , Math . PI , Math . PI / 2 , right , top ,
52- new Victor ( cx - halfStroke , top ) , new Victor ( right , cy + halfStroke ) )
90+ pushArcPath (
91+ paths ,
92+ innerRadius ,
93+ Math . PI ,
94+ Math . PI / 2 ,
95+ right ,
96+ top ,
97+ new Victor ( cx + halfStroke , top ) ,
98+ new Victor ( right , cy - halfStroke ) ,
99+ )
100+ pushArcPath (
101+ paths ,
102+ outerRadius ,
103+ Math . PI ,
104+ Math . PI / 2 ,
105+ right ,
106+ top ,
107+ new Victor ( cx - halfStroke , top ) ,
108+ new Victor ( right , cy + halfStroke ) ,
109+ )
53110
54111 // Bottom-left corner arcs
55- pushArcPath ( paths , innerRadius , 0 , - Math . PI / 2 , left , bottom ,
56- new Victor ( cx - halfStroke , bottom ) , new Victor ( left , cy + halfStroke ) )
57- pushArcPath ( paths , outerRadius , 0 , - Math . PI / 2 , left , bottom ,
58- new Victor ( cx + halfStroke , bottom ) , new Victor ( left , cy - halfStroke ) )
112+ pushArcPath (
113+ paths ,
114+ innerRadius ,
115+ 0 ,
116+ - Math . PI / 2 ,
117+ left ,
118+ bottom ,
119+ new Victor ( cx - halfStroke , bottom ) ,
120+ new Victor ( left , cy + halfStroke ) ,
121+ )
122+ pushArcPath (
123+ paths ,
124+ outerRadius ,
125+ 0 ,
126+ - Math . PI / 2 ,
127+ left ,
128+ bottom ,
129+ new Victor ( cx + halfStroke , bottom ) ,
130+ new Victor ( left , cy - halfStroke ) ,
131+ )
59132 }
60133
61134 if ( tileBorder ) {
@@ -75,15 +148,42 @@ function drawArcTile(bounds, orientation, strokeWidth, tileBorder) {
75148
76149 const paths = [ ]
77150 const { left, right, top, bottom } = bounds
78- const baseRadius = ( bounds . size ?? ( right - left ) ) / 2
151+ const baseRadius = ( bounds . size ?? right - left ) / 2
79152 const { midLeft, midRight, midTop, midBottom } = getEdgeMidpoints ( bounds )
80153
81154 if ( orientation === 0 ) {
82155 pushArcPath ( paths , baseRadius , Math . PI / 2 , 0 , left , top , midLeft , midTop )
83- pushArcPath ( paths , baseRadius , - Math . PI / 2 , - Math . PI , right , bottom , midRight , midBottom )
156+ pushArcPath (
157+ paths ,
158+ baseRadius ,
159+ - Math . PI / 2 ,
160+ - Math . PI ,
161+ right ,
162+ bottom ,
163+ midRight ,
164+ midBottom ,
165+ )
84166 } else {
85- pushArcPath ( paths , baseRadius , Math . PI , Math . PI / 2 , right , top , midTop , midRight )
86- pushArcPath ( paths , baseRadius , 0 , - Math . PI / 2 , left , bottom , midBottom , midLeft )
167+ pushArcPath (
168+ paths ,
169+ baseRadius ,
170+ Math . PI ,
171+ Math . PI / 2 ,
172+ right ,
173+ top ,
174+ midTop ,
175+ midRight ,
176+ )
177+ pushArcPath (
178+ paths ,
179+ baseRadius ,
180+ 0 ,
181+ - Math . PI / 2 ,
182+ left ,
183+ bottom ,
184+ midBottom ,
185+ midLeft ,
186+ )
87187 }
88188
89189 if ( tileBorder ) {
0 commit comments