Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def update_painters(self, view):
sloppiness = self.properties.get("diagram.sloppiness", 0)
if sloppiness:
view.painter = FreeHandPainter(ItemPainter(), sloppiness)
view.bounding_box_painter = FreeHandPainter(
BoundingBoxPainter(), sloppiness
)
else:
view.painter = ItemPainter()
def update_painters(self, view):
sloppiness = self.properties.get("diagram.sloppiness", 0)
if sloppiness:
view.painter = FreeHandPainter(ItemPainter(), sloppiness)
view.bounding_box_painter = FreeHandPainter(
BoundingBoxPainter(), sloppiness
)
else:
view.painter = ItemPainter()
def set_drawing_style(self, sloppiness=0.0):
"""
Set the drawing style for the diagram. 0.0 is straight,
2.0 is very sloppy. If the sloppiness is set to be anything
greater than 0.0, the FreeHandPainter instances will be used
for both the item painter and the box painter. Otherwise, by
default, the ItemPainter is used for the item and
BoundingBoxPainter for the box.
"""
assert self.view
view = self.view
if sloppiness:
item_painter = FreeHandPainter(ItemPainter(), sloppiness=sloppiness)
box_painter = FreeHandPainter(BoundingBoxPainter(), sloppiness=sloppiness)
else:
item_painter = ItemPainter()
box_painter = BoundingBoxPainter()
view.painter = (
PainterChain()
.append(item_painter)
.append(HandlePainter())
.append(FocusedItemPainter())
.append(ToolPainter())
)
view.bounding_box_painter = box_painter
view.queue_draw_refresh()