MCPcopy Create free account
hub / github.com/PageBot/PageBot / checkStyleArgs

Method checkStyleArgs

Lib/pagebot/elements/element.py:1538–1558  ·  view source on GitHub ↗

Fix style values where necessary. TODO: make sure keys are correct. >>> e = Element() >>> style = dict(fill=(1, 0, 0), stroke=0.5) >>> e.checkStyleArgs(style) >>> style['fill'] Color(r=1, g=0, b=0) >>> style['stroke'] Color(r=0.5, g=0.

(self, d)

Source from the content-addressed store, hash-verified

1536 return default
1537
1538 def checkStyleArgs(self, d):
1539 """Fix style values where necessary.
1540 TODO: make sure keys are correct.
1541
1542 >>> e = Element()
1543 >>> style = dict(fill=(1, 0, 0), stroke=0.5)
1544 >>> e.checkStyleArgs(style)
1545 >>> style['fill']
1546 Color(r=1, g=0, b=0)
1547 >>> style['stroke']
1548 Color(r=0.5, g=0.5, b=0.5)
1549 """
1550 fill = d.get('fill')
1551
1552 if fill is not None and not isinstance(fill, Color):
1553 d['fill'] = color(fill)
1554
1555 stroke = d.get('stroke')
1556
1557 if stroke is not None and not isinstance(stroke, Color):
1558 d['stroke'] = color(stroke)
1559
1560 def getNamedStyle(self, styleName):
1561 """In case we are looking for a named style (e.g. used by the

Callers 1

__init__Method · 0.95

Calls 2

colorFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected