@@ -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 :
@@ -1348,13 +1348,13 @@ def addGouraudTriangles(self, points, colors):
1348
1348
1349
1349
Parameters
1350
1350
----------
1351
-
1352
1351
points : np.ndarray
1353
- triangle vertices, shape (n, 3, 2)
1354
- where n = number of triangles, 3 = vertices, 2 = x, y
1352
+ Triangle vertices, shape (n, 3, 2)
1353
+ where n = number of triangles, 3 = vertices, 2 = x, y.
1355
1354
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)
1355
+ Vertex colors, shape (n, 3, 1) or (n, 3, 4)
1356
+ as with points, but last dimension is either (gray,)
1357
+ or (r, g, b, alpha).
1358
1358
1359
1359
Returns
1360
1360
-------
@@ -1387,9 +1387,12 @@ def writeGouraudTriangles(self):
1387
1387
'BitsPerCoordinate' : 32 ,
1388
1388
'BitsPerComponent' : 8 ,
1389
1389
'BitsPerFlag' : 8 ,
1390
- 'ColorSpace' : Name ('DeviceRGB' if colordim == 3 else 'DeviceGray' ),
1390
+ 'ColorSpace' : Name (
1391
+ 'DeviceRGB' if colordim == 3 else 'DeviceGray'
1392
+ ),
1391
1393
'AntiAlias' : False ,
1392
- 'Decode' : ([points_min [0 ], points_max [0 ], points_min [1 ], points_max [1 ]]
1394
+ 'Decode' : ([points_min [0 ], points_max [0 ],
1395
+ points_min [1 ], points_max [1 ]]
1393
1396
+ [0 , 1 ] * colordim ),
1394
1397
})
1395
1398
@@ -1904,21 +1907,21 @@ def draw_gouraud_triangles(self, gc, points, colors, trans):
1904
1907
assert colors .ndim == 3
1905
1908
assert colors .shape [1 ] == 3
1906
1909
assert colors .shape [2 ] in (1 , 4 )
1907
-
1910
+
1908
1911
shape = points .shape
1909
1912
points = points .reshape ((shape [0 ] * shape [1 ], 2 ))
1910
1913
tpoints = trans .transform (points )
1911
1914
tpoints = tpoints .reshape (shape )
1912
1915
name , _ = self .file .addGouraudTriangles (tpoints , colors )
1913
1916
output = self .file .output
1914
-
1917
+
1915
1918
if colors .shape [2 ] == 1 :
1916
1919
# grayscale
1917
1920
gc .set_alpha (1.0 )
1918
1921
self .check_gc (gc )
1919
1922
output (name , Op .shading )
1920
1923
return
1921
-
1924
+
1922
1925
alpha = colors [0 , 0 , 3 ]
1923
1926
if np .allclose (alpha , colors [:, :, 3 ]):
1924
1927
# single alpha value
0 commit comments