1+ use log:: warn;
12use lyon_geom:: { LineSegment , Point } ;
23
34use crate :: turtle:: elements:: { DrawCommand , FillPolygon , FillRule , Stroke } ;
@@ -161,6 +162,25 @@ pub(crate) fn into_fill_polygons(subpaths: Vec<Stroke>, fill_rule: FillRule) ->
161162 } )
162163 . collect ( ) ;
163164
165+ // TODO: EvenOdd fill for overlapping but non-nested subpaths isn't handled.
166+ // We need to XOR without flattening somehow.
167+ if fill_rule == FillRule :: EvenOdd {
168+ let bboxes: Vec < _ > = subpaths. iter ( ) . map ( |s| s. bounding_box ( ) ) . collect ( ) ;
169+ for i in 0 ..subpaths. len ( ) {
170+ for j in ( i + 1 ) ..subpaths. len ( ) {
171+ let boxes_overlap = bboxes[ i] . intersects ( & bboxes[ j] ) ;
172+ let neither_contains_the_other =
173+ !containers[ i] . contains ( & j) && !containers[ j] . contains ( & i) ;
174+ if boxes_overlap && neither_contains_the_other {
175+ warn ! (
176+ "`even-odd` fill rule with overlapping (non-nested) subpaths is not implemented! this won't be drawn correctly"
177+ ) ;
178+ break ;
179+ }
180+ }
181+ }
182+ }
183+
164184 // Classify each subpath as outer (contributes filled area) or hole (removes it).
165185 let is_outer: Vec < Option < bool > > = match fill_rule {
166186 FillRule :: EvenOdd => containers
@@ -186,7 +206,8 @@ pub(crate) fn into_fill_polygons(subpaths: Vec<Stroke>, fill_rule: FillRule) ->
186206 if winding_inside == 0 {
187207 Some ( false )
188208 } else {
189- // Ignore (why?)
209+ // Attempting to fill a region inside an already-filled region.
210+ // If `winding_inside` was zero, it would be a hole.
190211 None
191212 }
192213 }
0 commit comments