sk::DrawHistory class

A manager that correctly stores history about modifications to a canvas, even if multiple users are drawing.

Contents

Public functions

auto pushNewLayer(bool const foreign = false) -> void -> auto
auto paintCanvas(QPainter*const painter) -> void -> auto
Draws the last layer for each user.
auto drawAt(QPoint const& pos, DrawMode& mode, bool const foreign = false) -> void -> auto

Function documentation

auto sk::DrawHistory::pushNewLayer(bool const foreign = false) -> void

Creates a new layer that copies the image of the previous one, being able to draw over it next time. This is how history tracking works.

When multiple users are drawing, there is at most one CachedLayers for each one, limiting the history on frequent alternative drawings, but works well with many consecutive modifications made by one user. This is a tradeoff we've taken since keeping two drawings in sync over the network proved to be way out of our league.

auto sk::DrawHistory::drawAt(QPoint const& pos, DrawMode& mode, bool const foreign = false) -> void

Just draws with current pen/brush on the canvas on given position.