MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _soft_mask_state

Method _soft_mask_state

lib/matplotlib/backends/backend_pdf.py:1392–1442  ·  view source on GitHub ↗

Return an ExtGState that sets the soft mask to the given shading. Parameters ---------- smask : Reference Reference to a shading in DeviceGray color space, whose luminosity is to be used as the alpha channel. Returns -------

(self, smask)

Source from the content-addressed store, hash-verified

1390 return name
1391
1392 def _soft_mask_state(self, smask):
1393 """
1394 Return an ExtGState that sets the soft mask to the given shading.
1395
1396 Parameters
1397 ----------
1398 smask : Reference
1399 Reference to a shading in DeviceGray color space, whose luminosity
1400 is to be used as the alpha channel.
1401
1402 Returns
1403 -------
1404 Name
1405 """
1406
1407 state = self._soft_mask_states.get(smask, None)
1408 if state is not None:
1409 return state[0]
1410
1411 name = next(self._soft_mask_seq)
1412 groupOb = self.reserveObject('transparency group for soft mask')
1413 self._soft_mask_states[smask] = (
1414 name,
1415 {
1416 'Type': Name('ExtGState'),
1417 'AIS': False,
1418 'SMask': {
1419 'Type': Name('Mask'),
1420 'S': Name('Luminosity'),
1421 'BC': [1],
1422 'G': groupOb
1423 }
1424 }
1425 )
1426 self._soft_mask_groups.append((
1427 groupOb,
1428 {
1429 'Type': Name('XObject'),
1430 'Subtype': Name('Form'),
1431 'FormType': 1,
1432 'Group': {
1433 'S': Name('Transparency'),
1434 'CS': Name('DeviceGray')
1435 },
1436 'Matrix': [1, 0, 0, 1, 0, 0],
1437 'Resources': {'Shading': {'S': smask}},
1438 'BBox': [0, 0, 1, 1]
1439 },
1440 [Name('S'), Op.shading]
1441 ))
1442 return name
1443
1444 def writeExtGSTates(self):
1445 self.writeObject(

Callers 1

Calls 3

reserveObjectMethod · 0.95
NameClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected