Painters#

Painters are used to draw the view.

Protocols#

Each painter adheres to the Painter protocol.

class gaphas.painter.Painter(*args, **kwargs)[source]#

Painter interface.

paint(items: Collection[Item], cairo: cairo.Context) None[source]#

Do the paint action (called from the View).

Some painters, such as FreeHandPainter and BoundingBoxPainter, require a special painter protocol:

class gaphas.painter.painter.ItemPainterType(*args, **kwargs)[source]#
paint_item(item: Item, cairo: cairo.Context) None[source]#

Draw a single item.

paint(items: Collection[Item], cairo: cairo.Context) None[source]#

Do the paint action (called from the View).

Default implementations#

class gaphas.painter.PainterChain[source]#

Chain up a set of painters.

append(painter: Painter) PainterChain[source]#

Add a painter to the list of painters.

prepend(painter: Painter) PainterChain[source]#

Add a painter to the beginning of the list of painters.

class gaphas.painter.ItemPainter(selection: Selection | None = None)[source]#
class gaphas.painter.HandlePainter(view: GtkView)[source]#

Draw handles of items that are marked as selected in the view.

class gaphas.painter.FreeHandPainter(item_painter: ItemPainterType, sloppiness: float = 0.5)[source]#

This painter is a wrapper for an Item painter. The Cairo context is modified to allow for a sloppy, hand written drawing style.

Range [0..2.0] gives acceptable results.

  • Draftsman: 0.0

  • Artist: 0.25

  • Cartoonist: 0.5

  • Child: 1.0

  • Drunk: 2.0

Rubberband tool#

A special painter is used to display rubberband selection. This painter shares some state with the rubberband tool.