Source code for gaphas.painter.painter

"""The painter module provides different painters for parts of the canvas.

Painters can be swapped in and out.

Each painter takes care of a layer in the canvas (such as grid, items
and handles).
"""

from typing import Collection, Protocol

from cairo import Context as CairoContext

from gaphas.item import Item


[docs] class Painter(Protocol): """Painter interface."""
[docs] def paint(self, items: Collection[Item], cairo: CairoContext) -> None: """Do the paint action (called from the View).""" pass
[docs] class ItemPainterType(Protocol):
[docs] def paint_item(self, item: Item, cairo: CairoContext) -> None: """Draw a single item."""
[docs] def paint(self, items: Collection[Item], cairo: CairoContext) -> None: """Do the paint action (called from the View).""" pass