@@ -146,20 +146,24 @@ impl ElementFrame {
146146 path. line_to ( self . corner ( c0, BorderBox ) ) ;
147147 } else {
148148 match self . corner_needs_infill ( c0) {
149- true => path. insert_arc ( self . arc ( c0, PaddingBox , edge, Anticlockwise ) ) ,
149+ true => {
150+ path. insert_arc ( self . partial_corner_arc ( c0, PaddingBox , edge, Anticlockwise ) )
151+ }
150152 false => path. move_to ( self . corner ( c0, PaddingBox ) ) ,
151153 }
152- path. insert_arc ( self . arc ( c0, BorderBox , edge, Clockwise ) ) ;
154+ path. insert_arc ( self . partial_corner_arc ( c0, BorderBox , edge, Clockwise ) ) ;
153155 }
154156
155157 // 2. Second corner
156158 if self . is_sharp ( c1, BorderBox ) {
157159 path. line_to ( self . corner ( c1, BorderBox ) ) ;
158160 path. line_to ( self . corner ( c1, PaddingBox ) ) ;
159161 } else {
160- path. insert_arc ( self . arc ( c1, BorderBox , edge, Clockwise ) ) ;
162+ path. insert_arc ( self . partial_corner_arc ( c1, BorderBox , edge, Clockwise ) ) ;
161163 match self . corner_needs_infill ( c1) {
162- true => path. insert_arc ( self . arc ( c1, PaddingBox , edge, Anticlockwise ) ) ,
164+ true => {
165+ path. insert_arc ( self . partial_corner_arc ( c1, PaddingBox , edge, Anticlockwise ) )
166+ }
163167 false => path. line_to ( self . corner ( c1, PaddingBox ) ) ,
164168 }
165169 }
@@ -214,7 +218,7 @@ impl ElementFrame {
214218 if self . is_sharp ( corner, line) {
215219 path. insert_point ( self . corner ( corner, line) ) ;
216220 } else {
217- path. insert_arc ( self . full_arc ( corner, line, direction) ) ;
221+ path. insert_arc ( self . corner_arc ( corner, line, direction) ) ;
218222 }
219223 }
220224 }
@@ -237,7 +241,7 @@ impl ElementFrame {
237241 path. move_to ( self . corner ( TopLeft , CssBox :: BorderBox ) ) ;
238242 } else {
239243 const TOLERANCE : f64 = 0.1 ;
240- let arc = self . full_arc ( TopLeft , CssBox :: BorderBox , Direction :: Anticlockwise ) ;
244+ let arc = self . corner_arc ( TopLeft , CssBox :: BorderBox , Direction :: Anticlockwise ) ;
241245 let elements = arc. path_elements ( TOLERANCE ) ;
242246 path. extend ( elements) ;
243247 }
@@ -246,7 +250,11 @@ impl ElementFrame {
246250 if self . is_sharp ( corner, CssBox :: BorderBox ) {
247251 path. insert_point ( self . corner ( corner, CssBox :: BorderBox ) ) ;
248252 } else {
249- path. insert_arc ( self . full_arc ( corner, CssBox :: BorderBox , Direction :: Anticlockwise ) ) ;
253+ path. insert_arc ( self . corner_arc (
254+ corner,
255+ CssBox :: BorderBox ,
256+ Direction :: Anticlockwise ,
257+ ) ) ;
250258 }
251259 }
252260 }
@@ -301,8 +309,8 @@ impl ElementFrame {
301309 }
302310
303311 /// Get the complete arc for a corner, skipping the need for splitting the arc into pieces
304- fn full_arc ( & self , corner : Corner , side : CssBox , direction : Direction ) -> Arc {
305- let ellipse = self . ellipse ( corner, side ) ;
312+ fn corner_arc ( & self , corner : Corner , css_box : CssBox , direction : Direction ) -> Arc {
313+ let ellipse = self . ellipse ( corner, css_box ) ;
306314
307315 // Sweep clockwise for outer arcs, counter clockwise for inner arcs
308316 let sweep_direction = match direction {
@@ -333,14 +341,24 @@ impl ElementFrame {
333341 )
334342 }
335343
336- /// Get the partial arc for a corner
344+ /// Get the arc for a half of a corner.
345+ /// This handles the case where adjacent border sides have different colors and thus
346+ /// the corner between the side changes color in the middle. We draw these as separate shapes
347+ /// and thus need to to get the arc up to the "middle point".
337348 ///
338- fn arc ( & self , corner : Corner , side : CssBox , edge : Edge , direction : Direction ) -> Arc {
349+ /// The angle at which the color changes depends on the ratio of the border widths and radii of the corner
350+ fn partial_corner_arc (
351+ & self ,
352+ corner : Corner ,
353+ css_box : CssBox ,
354+ edge : Edge ,
355+ direction : Direction ,
356+ ) -> Arc {
339357 use Corner :: * ;
340358 use CssBox :: * ;
341359 use Edge :: * ;
342360
343- let ellipse = self . ellipse ( corner, side ) ;
361+ let ellipse = self . ellipse ( corner, css_box ) ;
344362
345363 // We solve a tiny system of equations to find the start angle
346364 // This is fixed to a single coordinate system, so we need to adjust the start angle
@@ -369,7 +387,7 @@ impl ElementFrame {
369387 // Depededning on the edge, we need to adjust the start angle
370388 // We still sweep the same, but the theta split is different since we're cutting in half
371389 // I imagine you could mnake this simpler using a bit more math
372- let start = match ( edge, corner, side ) {
390+ let start = match ( edge, corner, css_box ) {
373391 // Top Edge
374392 ( Top , TopLeft , PaddingBox ) => 0.0 ,
375393 ( Top , TopLeft , BorderBox ) => -theta,
0 commit comments