@@ -92,7 +92,7 @@ def draw(self, renderer):
9292 renderer .close_blend_group ()
9393
9494
95- def plot_blend_group_types (rasterize = False ):
95+ def plot_blend_group_types (rasterize = False , porterduff = False ):
9696 # Rows: top row is non-isolated, bottom row is isolated
9797 # Columns: left column is non-knockout, right column is knockout
9898 fig , axs = plt .subplots (2 , 2 , figsize = (3 , 3 ), dpi = 80 , layout = 'constrained' )
@@ -128,6 +128,18 @@ def plot_blend_group_types(rasterize=False):
128128 gray = Circle ((0 , 0 ), 0.1 , fc = 'gray' , zorder = 0 )
129129 axs [i , j ].add_artist (gray )
130130
131+ # For backends that support the Porter-Duff compositing operators, additionally
132+ # test 'knockout' and 'clear' as the blend mode for an isolated group
133+ if porterduff :
134+ for x , group_blend_mode , group_alpha in [(- 0.6 , 'knockout' , 1 ),
135+ (- 0.2 , 'knockout' , 0.6 ),
136+ (0.2 , 'clear' , 0.6 ),
137+ (0.6 , 'clear' , 1 )]:
138+ circle = Circle ((x , - 0.8 ), 0.15 , fc = 'k' , alpha = 0.75 )
139+ group = ArtistGroup ([circle ], group_blend_mode = group_blend_mode ,
140+ group_alpha = group_alpha )
141+ axs [1 , 0 ].add_artist (group )
142+
131143
132144@image_comparison (['blend_modes_agg.png' ], style = 'mpl20' )
133145def test_blend_modes_agg ():
@@ -183,7 +195,7 @@ def test_blend_groups_agg():
183195 # The top-right panel (knockout but not isolated) is not supported, so will be
184196 # rendered like the top-left panel (neither knockout nor isolated)
185197
186- plot_blend_group_types ()
198+ plot_blend_group_types (porterduff = True )
187199
188200
189201@pytest .mark .backend ('cairo' )
@@ -192,7 +204,7 @@ def test_blend_groups_cairo():
192204 # The top-right panel (knockout but not isolated) is not supported, so will be
193205 # rendered like the top-left panel (neither knockout nor isolated)
194206
195- plot_blend_group_types ()
207+ plot_blend_group_types (porterduff = True )
196208
197209
198210@image_comparison (['blend_groups_svg.svg' ], style = 'mpl20' )
0 commit comments