@@ -769,7 +769,7 @@ mod impls {
769769 & rect,
770770 ) ;
771771 let alpha = params. time . sin ( ) as f32 * 0.5 + 0.5 ;
772- scene. push_layer ( Mix :: Normal , alpha, Affine :: IDENTITY , & rect) ;
772+ scene. push_layer ( Fill :: NonZero , Mix :: Normal , alpha, Affine :: IDENTITY , & rect) ;
773773 scene. fill (
774774 Fill :: NonZero ,
775775 Affine :: translate ( ( 100.0 , 100.0 ) ) * Affine :: scale ( 0.2 ) ,
@@ -1125,6 +1125,7 @@ mod impls {
11251125 let mut depth = 0 ;
11261126 for ( width, color) in & options[ ..params. complexity . min ( options. len ( ) - 1 ) ] {
11271127 scene. push_layer (
1128+ Fill :: NonZero ,
11281129 Mix :: Normal ,
11291130 0.9 ,
11301131 Affine :: IDENTITY ,
@@ -1152,7 +1153,7 @@ mod impls {
11521153 const CLIPS_PER_FILL : usize = 3 ;
11531154 for _ in 0 ..CLIPS_PER_FILL {
11541155 let rot = Affine :: rotate ( rng. random_range ( 0.0 ..PI ) ) ;
1155- scene. push_clip_layer ( translate * rot, & base_tri) ;
1156+ scene. push_clip_layer ( Fill :: NonZero , translate * rot, & base_tri) ;
11561157 }
11571158 let rot = Affine :: rotate ( rng. random_range ( 0.0 ..PI ) ) ;
11581159 let color = Color :: new ( [ rng. random ( ) , rng. random ( ) , rng. random ( ) , 1. ] ) ;
@@ -1212,7 +1213,7 @@ mod impls {
12121213 PathEl :: LineTo ( ( X0 , Y1 ) . into ( ) ) ,
12131214 PathEl :: ClosePath ,
12141215 ] ;
1215- scene. push_clip_layer ( Affine :: IDENTITY , & path) ;
1216+ scene. push_clip_layer ( Fill :: NonZero , Affine :: IDENTITY , & path) ;
12161217 }
12171218 let rect = Rect :: new ( X0 , Y0 , X1 , Y1 ) ;
12181219 scene. fill (
@@ -1243,7 +1244,11 @@ mod impls {
12431244 None ,
12441245 & make_diamond ( 1024.0 , 125.0 ) ,
12451246 ) ;
1246- scene. push_clip_layer ( Affine :: IDENTITY , & make_diamond ( 1024.0 , 150.0 ) ) ;
1247+ scene. push_clip_layer (
1248+ Fill :: NonZero ,
1249+ Affine :: IDENTITY ,
1250+ & make_diamond ( 1024.0 , 150.0 ) ,
1251+ ) ;
12471252 scene. fill (
12481253 Fill :: NonZero ,
12491254 Affine :: IDENTITY ,
@@ -1271,11 +1276,11 @@ mod impls {
12711276 scene. fill ( Fill :: NonZero , transform, & radial, None , & rect) ;
12721277 }
12731278 const COLORS : & [ Color ] = & [ palette:: css:: RED , palette:: css:: LIME , palette:: css:: BLUE ] ;
1274- scene. push_layer ( Mix :: Normal , 1.0 , transform, & rect) ;
1279+ scene. push_layer ( Fill :: NonZero , Mix :: Normal , 1.0 , transform, & rect) ;
12751280 for ( i, c) in COLORS . iter ( ) . enumerate ( ) {
12761281 let linear = Gradient :: new_linear ( ( 0.0 , 0.0 ) , ( 0.0 , 200.0 ) )
12771282 . with_stops ( [ palette:: css:: WHITE , * c] ) ;
1278- scene. push_layer ( blend, 1.0 , transform, & rect) ;
1283+ scene. push_layer ( Fill :: NonZero , blend, 1.0 , transform, & rect) ;
12791284 // squash the ellipse
12801285 let a = transform
12811286 * Affine :: translate ( ( 100. , 100. ) )
@@ -1579,7 +1584,7 @@ mod impls {
15791584 PathEl :: ClosePath ,
15801585 ]
15811586 } ;
1582- scene. push_clip_layer ( Affine :: IDENTITY , & clip) ;
1587+ scene. push_clip_layer ( Fill :: NonZero , Affine :: IDENTITY , & clip) ;
15831588 {
15841589 let text_size = 60.0 + 40.0 * ( params. time as f32 ) . sin ( ) ;
15851590 let s = "Some clipped text!" ;
@@ -1594,6 +1599,37 @@ mod impls {
15941599 }
15951600 scene. pop_layer ( ) ;
15961601
1602+ // Even-odd clip-layer demo: two nested rectangles with the same winding should form a ring.
1603+ let demo_rect = Rect :: new ( 250.0 , 20.0 , 450.0 , 220.0 ) ;
1604+ scene. fill (
1605+ Fill :: NonZero ,
1606+ Affine :: IDENTITY ,
1607+ palette:: css:: BLUE ,
1608+ None ,
1609+ & demo_rect,
1610+ ) ;
1611+ let demo_clip = [
1612+ PathEl :: MoveTo ( ( 250.0 , 20.0 ) . into ( ) ) ,
1613+ PathEl :: LineTo ( ( 450.0 , 20.0 ) . into ( ) ) ,
1614+ PathEl :: LineTo ( ( 450.0 , 220.0 ) . into ( ) ) ,
1615+ PathEl :: LineTo ( ( 250.0 , 220.0 ) . into ( ) ) ,
1616+ PathEl :: ClosePath ,
1617+ PathEl :: MoveTo ( ( 310.0 , 80.0 ) . into ( ) ) ,
1618+ PathEl :: LineTo ( ( 390.0 , 80.0 ) . into ( ) ) ,
1619+ PathEl :: LineTo ( ( 390.0 , 160.0 ) . into ( ) ) ,
1620+ PathEl :: LineTo ( ( 310.0 , 160.0 ) . into ( ) ) ,
1621+ PathEl :: ClosePath ,
1622+ ] ;
1623+ scene. push_clip_layer ( Fill :: EvenOdd , Affine :: IDENTITY , & demo_clip) ;
1624+ scene. fill (
1625+ Fill :: NonZero ,
1626+ Affine :: IDENTITY ,
1627+ palette:: css:: RED ,
1628+ None ,
1629+ & demo_rect,
1630+ ) ;
1631+ scene. pop_layer ( ) ;
1632+
15971633 let large_background_rect = Rect :: new ( -1000.0 , -1000.0 , 2000.0 , 2000.0 ) ;
15981634 let inside_clip_rect = Rect :: new ( 11.0 , 13.399999999999999 , 59.0 , 56.6 ) ;
15991635 let outside_clip_rect = Rect :: new (
@@ -1606,6 +1642,7 @@ mod impls {
16061642 let scale = 2.0 ;
16071643
16081644 scene. push_layer (
1645+ Fill :: NonZero ,
16091646 BlendMode {
16101647 mix : Mix :: Normal ,
16111648 compose : Compose :: SrcOver ,
@@ -1926,6 +1963,7 @@ mod impls {
19261963 } ,
19271964 ) ;
19281965 scene. push_layer (
1966+ Fill :: NonZero ,
19291967 BlendMode :: new ( Mix :: Normal , Compose :: SrcOver ) ,
19301968 1.0 ,
19311969 Affine :: IDENTITY ,
@@ -1949,6 +1987,7 @@ mod impls {
19491987 } ,
19501988 ) ;
19511989 scene. push_luminance_mask_layer (
1990+ Fill :: NonZero ,
19521991 1.0 ,
19531992 Affine :: IDENTITY ,
19541993 & Rect {
@@ -1993,6 +2032,7 @@ mod impls {
19932032 . unwrap ( ) ;
19942033 // HACK: Porter-Duff "over" the base color, restoring full alpha
19952034 scene. push_layer (
2035+ Fill :: NonZero ,
19962036 BlendMode :: new ( Mix :: Normal , Compose :: SrcOver ) ,
19972037 1.0 ,
19982038 Affine :: IDENTITY ,
@@ -2028,6 +2068,7 @@ mod impls {
20282068 } ,
20292069 ) ;
20302070 scene. push_luminance_mask_layer (
2071+ Fill :: NonZero ,
20312072 1.0 ,
20322073 Affine :: IDENTITY ,
20332074 & Rect {
0 commit comments