Week 3 recap - points on a canvas

·

2 min read

Hey welcome to the week 3 recap blog. So after some testing, using the pixel art brush preset and clicking on individual pixels on the canvas will trigger functions like kis_paintop:paintAt and kis_brushop:paintAt. KisBrushOp represents a specific painting operation or brush stroke. It defines how the paint is applied to the canvas. Functionally it encapsulates the logic for a particular brush type, such as how it interacts with the canvas, how it handles pressure sensitivity, and other brush-specific behaviors. It also contains parameters and settings specific to a brush such as size, shape, opacity, and blending mode. Also, it handles the actual application of paint, typically involving complex algorithms for rendering brush strokes. So different brush types like -pencil, airbrush, or watercolor would each have their own KisBrushOp implementation.

Kis painter is a higher-level utility class that uses ‘kisbrushop’ objects to perform painting tasks. It provides methods to paint various shapes and paths using the currently selected brush operation. Functionally it acts as an interface for performing painting actions such as drawing lines, polygons, and filling areas on the canvas. It also manages the sequence and coordination of painting actions, invoking the appropriate ‘kisbrushop’ method to apply paint. It also has higher-level abstractions for painting operations, such as filling a polygon or painting along a path.

With that out of the way, when the user starts holding down the cursor on the canvas KisToolFreehandHelper::paint is called instead which then ends up calling KisToolFreehandHelper::paintBezierSegment which makes an educated guess and tries to form two lines using calculated control points. I'm not sure what this means for something like the pixel art brush but it can be reasonable to assume that something in this ballpark should be modifiable to some degree for the pixel-perfect option.

KisPaintInformation gets passed along for most of these function calls and seems to store information about each paint event, including position (in QPointF pos() which is a class in Qt used to represent a point in the plane using floating point precision), pressure, time, rotation, velocity, etc. Krita also might be storing points in a history list based on some m_d->history calls. From here I'll be trying to figure out how to implement something like Libresprite's point system (explained in the last blog) in Krita which follows these points and ignores the corner pieces when drawing.