@@ -731,7 +731,7 @@ def __init__(self, filename, metadata=None):
731731 self ._soft_mask_states = {}
732732 self ._soft_mask_seq = (Name (f'SM{ i } ' ) for i in itertools .count (1 ))
733733 self ._soft_mask_groups = []
734- self .hatchPatterns = {}
734+ self ._hatch_patterns = {}
735735 self ._hatch_pattern_seq = (Name (f'H{ i } ' ) for i in itertools .count (1 ))
736736 self .gouraudTriangles = []
737737
@@ -1534,26 +1534,29 @@ def _write_soft_mask_groups(self):
15341534
15351535 def hatchPattern (self , hatch_style ):
15361536 # The colors may come in as numpy arrays, which aren't hashable
1537- if hatch_style is not None :
1538- edge , face , hatch = hatch_style
1539- if edge is not None :
1540- edge = tuple (edge )
1541- if face is not None :
1542- face = tuple (face )
1543- hatch_style = (edge , face , hatch )
1544-
1545- pattern = self .hatchPatterns .get (hatch_style , None )
1537+ edge , face , hatch , lw = hatch_style
1538+ if edge is not None :
1539+ edge = tuple (edge )
1540+ if face is not None :
1541+ face = tuple (face )
1542+ hatch_style = (edge , face , hatch , lw )
1543+
1544+ pattern = self ._hatch_patterns .get (hatch_style , None )
15461545 if pattern is not None :
15471546 return pattern
15481547
15491548 name = next (self ._hatch_pattern_seq )
1550- self .hatchPatterns [hatch_style ] = name
1549+ self ._hatch_patterns [hatch_style ] = name
15511550 return name
15521551
1552+ hatchPatterns = _api .deprecated ("3.10" )(property (lambda self : {
1553+ k : (e , f , h ) for k , (e , f , h , l ) in self ._hatch_patterns .items ()
1554+ }))
1555+
15531556 def writeHatches (self ):
15541557 hatchDict = dict ()
15551558 sidelen = 72.0
1556- for hatch_style , name in self .hatchPatterns .items ():
1559+ for hatch_style , name in self ._hatch_patterns .items ():
15571560 ob = self .reserveObject ('hatch pattern' )
15581561 hatchDict [name ] = ob
15591562 res = {'Procsets' :
@@ -1568,7 +1571,7 @@ def writeHatches(self):
15681571 # Change origin to match Agg at top-left.
15691572 'Matrix' : [1 , 0 , 0 , 1 , 0 , self .height * 72 ]})
15701573
1571- stroke_rgb , fill_rgb , hatch = hatch_style
1574+ stroke_rgb , fill_rgb , hatch , lw = hatch_style
15721575 self .output (stroke_rgb [0 ], stroke_rgb [1 ], stroke_rgb [2 ],
15731576 Op .setrgb_stroke )
15741577 if fill_rgb is not None :
@@ -1577,7 +1580,7 @@ def writeHatches(self):
15771580 0 , 0 , sidelen , sidelen , Op .rectangle ,
15781581 Op .fill )
15791582
1580- self .output (mpl . rcParams [ 'hatch.linewidth' ] , Op .setlinewidth )
1583+ self .output (lw , Op .setlinewidth )
15811584
15821585 self .output (* self .pathOperations (
15831586 Path .hatch (hatch ),
@@ -2508,14 +2511,14 @@ def alpha_cmd(self, alpha, forced, effective_alphas):
25082511 name = self .file .alphaState (effective_alphas )
25092512 return [name , Op .setgstate ]
25102513
2511- def hatch_cmd (self , hatch , hatch_color ):
2514+ def hatch_cmd (self , hatch , hatch_color , hatch_linewidth ):
25122515 if not hatch :
25132516 if self ._fillcolor is not None :
25142517 return self .fillcolor_cmd (self ._fillcolor )
25152518 else :
25162519 return [Name ('DeviceRGB' ), Op .setcolorspace_nonstroke ]
25172520 else :
2518- hatch_style = (hatch_color , self ._fillcolor , hatch )
2521+ hatch_style = (hatch_color , self ._fillcolor , hatch , hatch_linewidth )
25192522 name = self .file .hatchPattern (hatch_style )
25202523 return [Name ('Pattern' ), Op .setcolorspace_nonstroke ,
25212524 name , Op .setcolor_nonstroke ]
@@ -2580,8 +2583,8 @@ def clip_cmd(self, cliprect, clippath):
25802583 (('_dashes' ,), dash_cmd ),
25812584 (('_rgb' ,), rgb_cmd ),
25822585 # must come after fillcolor and rgb
2583- (('_hatch' , '_hatch_color' ), hatch_cmd ),
2584- )
2586+ (('_hatch' , '_hatch_color' , '_hatch_linewidth' ), hatch_cmd ),
2587+ )
25852588
25862589 def delta (self , other ):
25872590 """
@@ -2609,11 +2612,11 @@ def delta(self, other):
26092612 break
26102613
26112614 # Need to update hatching if we also updated fillcolor
2612- if params == ( '_hatch' , '_hatch_color' ) and fill_performed :
2615+ if cmd . __name__ == 'hatch_cmd' and fill_performed :
26132616 different = True
26142617
26152618 if different :
2616- if params == ( '_fillcolor' ,) :
2619+ if cmd . __name__ == 'fillcolor_cmd' :
26172620 fill_performed = True
26182621 theirs = [getattr (other , p ) for p in params ]
26192622 cmds .extend (cmd (self , * theirs ))
0 commit comments