@@ -1222,13 +1222,13 @@ def alphaState(self, alpha):
1222
1222
return name
1223
1223
1224
1224
def _soft_mask_state (self , smask ):
1225
- """Return the name of an ExtGState that sets the soft mask to the given shading.
1225
+ """Return an ExtGState that sets the soft mask to the given shading.
1226
1226
1227
1227
Parameters
1228
1228
----------
1229
1229
smask : Reference
1230
- reference to a shading in DeviceGray color space, whose luminosity is
1231
- to be used as the alpha channel
1230
+ Reference to a shading in DeviceGray color space, whose luminosity
1231
+ is to be used as the alpha channel.
1232
1232
1233
1233
Returns
1234
1234
-------
@@ -1286,7 +1286,7 @@ def _write_soft_mask_groups(self):
1286
1286
self .beginStream (ob .id , None , attributes )
1287
1287
self .output (* content )
1288
1288
self .endStream ()
1289
-
1289
+
1290
1290
def hatchPattern (self , hatch_style ):
1291
1291
# The colors may come in as numpy arrays, which aren't hashable
1292
1292
if hatch_style is not None :
@@ -1350,11 +1350,12 @@ def addGouraudTriangles(self, points, colors):
1350
1350
----------
1351
1351
1352
1352
points : np.ndarray
1353
- triangle vertices, shape (n, 3, 2)
1354
- where n = number of triangles, 3 = vertices, 2 = x, y
1353
+ Triangle vertices, shape (n, 3, 2)
1354
+ where n = number of triangles, 3 = vertices, 2 = x, y.
1355
1355
colors : np.ndarray
1356
- vertex colors, shape (n, 3, 1) or (n, 3, 4)
1357
- as with points, but last dimension is either (gray,) or (r, g, b, alpha)
1356
+ Vertex colors, shape (n, 3, 1) or (n, 3, 4)
1357
+ as with points, but last dimension is either (gray,)
1358
+ or (r, g, b, alpha).
1358
1359
1359
1360
Returns
1360
1361
-------
@@ -1387,9 +1388,12 @@ def writeGouraudTriangles(self):
1387
1388
'BitsPerCoordinate' : 32 ,
1388
1389
'BitsPerComponent' : 8 ,
1389
1390
'BitsPerFlag' : 8 ,
1390
- 'ColorSpace' : Name ('DeviceRGB' if colordim == 3 else 'DeviceGray' ),
1391
+ 'ColorSpace' : Name (
1392
+ 'DeviceRGB' if colordim == 3 else 'DeviceGray'
1393
+ ),
1391
1394
'AntiAlias' : False ,
1392
- 'Decode' : ([points_min [0 ], points_max [0 ], points_min [1 ], points_max [1 ]]
1395
+ 'Decode' : ([points_min [0 ], points_max [0 ],
1396
+ points_min [1 ], points_max [1 ]]
1393
1397
+ [0 , 1 ] * colordim ),
1394
1398
})
1395
1399
@@ -1904,21 +1908,21 @@ def draw_gouraud_triangles(self, gc, points, colors, trans):
1904
1908
assert colors .ndim == 3
1905
1909
assert colors .shape [1 ] == 3
1906
1910
assert colors .shape [2 ] in (1 , 4 )
1907
-
1911
+
1908
1912
shape = points .shape
1909
1913
points = points .reshape ((shape [0 ] * shape [1 ], 2 ))
1910
1914
tpoints = trans .transform (points )
1911
1915
tpoints = tpoints .reshape (shape )
1912
1916
name , _ = self .file .addGouraudTriangles (tpoints , colors )
1913
1917
output = self .file .output
1914
-
1918
+
1915
1919
if colors .shape [2 ] == 1 :
1916
1920
# grayscale
1917
1921
gc .set_alpha (1.0 )
1918
1922
self .check_gc (gc )
1919
1923
output (name , Op .shading )
1920
1924
return
1921
-
1925
+
1922
1926
alpha = colors [0 , 0 , 3 ]
1923
1927
if np .allclose (alpha , colors [:, :, 3 ]):
1924
1928
# single alpha value
0 commit comments