@@ -731,7 +731,7 @@ def __init__(self, filename, metadata=None):
731
731
self ._soft_mask_states = {}
732
732
self ._soft_mask_seq = (Name (f'SM{ i } ' ) for i in itertools .count (1 ))
733
733
self ._soft_mask_groups = []
734
- self .hatchPatterns = {}
734
+ self ._hatch_patterns = {}
735
735
self ._hatch_pattern_seq = (Name (f'H{ i } ' ) for i in itertools .count (1 ))
736
736
self .gouraudTriangles = []
737
737
@@ -1534,26 +1534,29 @@ def _write_soft_mask_groups(self):
1534
1534
1535
1535
def hatchPattern (self , hatch_style ):
1536
1536
# 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 )
1546
1545
if pattern is not None :
1547
1546
return pattern
1548
1547
1549
1548
name = next (self ._hatch_pattern_seq )
1550
- self .hatchPatterns [hatch_style ] = name
1549
+ self ._hatch_patterns [hatch_style ] = name
1551
1550
return name
1552
1551
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
+
1553
1556
def writeHatches (self ):
1554
1557
hatchDict = dict ()
1555
1558
sidelen = 72.0
1556
- for hatch_style , name in self .hatchPatterns .items ():
1559
+ for hatch_style , name in self ._hatch_patterns .items ():
1557
1560
ob = self .reserveObject ('hatch pattern' )
1558
1561
hatchDict [name ] = ob
1559
1562
res = {'Procsets' :
@@ -1568,7 +1571,7 @@ def writeHatches(self):
1568
1571
# Change origin to match Agg at top-left.
1569
1572
'Matrix' : [1 , 0 , 0 , 1 , 0 , self .height * 72 ]})
1570
1573
1571
- stroke_rgb , fill_rgb , hatch = hatch_style
1574
+ stroke_rgb , fill_rgb , hatch , lw = hatch_style
1572
1575
self .output (stroke_rgb [0 ], stroke_rgb [1 ], stroke_rgb [2 ],
1573
1576
Op .setrgb_stroke )
1574
1577
if fill_rgb is not None :
@@ -1577,7 +1580,7 @@ def writeHatches(self):
1577
1580
0 , 0 , sidelen , sidelen , Op .rectangle ,
1578
1581
Op .fill )
1579
1582
1580
- self .output (mpl . rcParams [ 'hatch.linewidth' ] , Op .setlinewidth )
1583
+ self .output (lw , Op .setlinewidth )
1581
1584
1582
1585
self .output (* self .pathOperations (
1583
1586
Path .hatch (hatch ),
@@ -2508,14 +2511,14 @@ def alpha_cmd(self, alpha, forced, effective_alphas):
2508
2511
name = self .file .alphaState (effective_alphas )
2509
2512
return [name , Op .setgstate ]
2510
2513
2511
- def hatch_cmd (self , hatch , hatch_color ):
2514
+ def hatch_cmd (self , hatch , hatch_color , hatch_linewidth ):
2512
2515
if not hatch :
2513
2516
if self ._fillcolor is not None :
2514
2517
return self .fillcolor_cmd (self ._fillcolor )
2515
2518
else :
2516
2519
return [Name ('DeviceRGB' ), Op .setcolorspace_nonstroke ]
2517
2520
else :
2518
- hatch_style = (hatch_color , self ._fillcolor , hatch )
2521
+ hatch_style = (hatch_color , self ._fillcolor , hatch , hatch_linewidth )
2519
2522
name = self .file .hatchPattern (hatch_style )
2520
2523
return [Name ('Pattern' ), Op .setcolorspace_nonstroke ,
2521
2524
name , Op .setcolor_nonstroke ]
@@ -2580,8 +2583,8 @@ def clip_cmd(self, cliprect, clippath):
2580
2583
(('_dashes' ,), dash_cmd ),
2581
2584
(('_rgb' ,), rgb_cmd ),
2582
2585
# must come after fillcolor and rgb
2583
- (('_hatch' , '_hatch_color' ), hatch_cmd ),
2584
- )
2586
+ (('_hatch' , '_hatch_color' , '_hatch_linewidth' ), hatch_cmd ),
2587
+ )
2585
2588
2586
2589
def delta (self , other ):
2587
2590
"""
@@ -2609,11 +2612,11 @@ def delta(self, other):
2609
2612
break
2610
2613
2611
2614
# 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 :
2613
2616
different = True
2614
2617
2615
2618
if different :
2616
- if params == ( '_fillcolor' ,) :
2619
+ if cmd . __name__ == 'fillcolor_cmd' :
2617
2620
fill_performed = True
2618
2621
theirs = [getattr (other , p ) for p in params ]
2619
2622
cmds .extend (cmd (self , * theirs ))
0 commit comments