krita
KisPainter Class Reference
#include <kis_painter.h>
Inheritance diagram for KisPainter:

Detailed Description
KisPainter contains the graphics primitives necessary to draw on a KisPaintDevice.This is the same kind of abstraction as used in Qt itself, where you have QPainter and QPaintDevice.
However, KisPainter works on a tiled image and supports different colour models, and that's a lot more complicated.
KisPainter supports transactions that can group various paint operations in one undoable step.
For more complex operations, you might want to have a look at the subclasses of KisPainter: KisConvolutionPainter, KisFillPainter and KisGradientPainter
Definition at line 56 of file kis_painter.h.
Public Types | |
enum | FillStyle { FillStyleNone, FillStyleForegroundColor, FillStyleBackgroundColor, FillStylePattern, FillStyleGradient, FillStyleStrokes } |
enum | StrokeStyle { StrokeStyleNone, StrokeStyleBrush } |
Public Member Functions | |
KisPainter () | |
KisPainter (KisPaintDeviceSP device) | |
virtual | ~KisPainter () |
void | begin (KisPaintDeviceSP device) |
KCommand * | end () |
void | beginTransaction (const QString &customName=QString::null) |
KCommand * | endTransaction () |
void | beginTransaction (KisTransaction *command) |
KisTransaction * | transaction () |
KisPaintDeviceSP | device () const |
void | bitBlt (Q_INT32 dx, Q_INT32 dy, const KisCompositeOp &op, KisPaintDeviceSP src, Q_INT32 sx, Q_INT32 sy, Q_INT32 sw, Q_INT32 sh) |
void | bitBlt (Q_INT32 dx, Q_INT32 dy, const KisCompositeOp &op, KisPaintDeviceSP src, Q_UINT8 opacity, Q_INT32 sx, Q_INT32 sy, Q_INT32 sw, Q_INT32 sh) |
void | bltMask (Q_INT32 dx, Q_INT32 dy, const KisCompositeOp &op, KisPaintDeviceSP src, KisPaintDeviceSP selMask, Q_UINT8 opacity, Q_INT32 sx, Q_INT32 sy, Q_INT32 sw, Q_INT32 sh) |
void | bltSelection (Q_INT32 dx, Q_INT32 dy, const KisCompositeOp &op, KisPaintDeviceSP src, KisSelectionSP selMask, Q_UINT8 opacity, Q_INT32 sx, Q_INT32 sy, Q_INT32 sw, Q_INT32 sh) |
void | bltSelection (Q_INT32 dx, Q_INT32 dy, const KisCompositeOp &op, KisPaintDeviceSP src, Q_UINT8 opacity, Q_INT32 sx, Q_INT32 sy, Q_INT32 sw, Q_INT32 sh) |
QRect | dirtyRect () |
QRect | addDirtyRect (QRect r) |
void | paintPolyline (const QValueVector< KisPoint > &points, int index=0, int numPoints=-1) |
double | paintLine (const KisPoint &pos1, const double pressure1, const double xTilt1, const double yTilt1, const KisPoint &pos2, const double pressure2, const double xTilt2, const double yTilt2, const double savedDist=-1) |
double | paintBezierCurve (const KisPoint &pos1, const double pressure1, const double xTilt1, const double yTilt1, const KisPoint &control1, const KisPoint &control2, const KisPoint &pos2, const double pressure2, const double xTilt2, const double yTilt2, const double savedDist=-1) |
void | getBezierCurvePoints (const KisPoint &pos1, const KisPoint &control1, const KisPoint &control2, const KisPoint &pos2, vKisPoint &points) |
void | paintRect (const KisPoint &startPoint, const KisPoint &endPoint, const double pressure, const double xTilt, const double yTilt) |
void | paintEllipse (const KisPoint &startPoint, const KisPoint &endPoint, const double pressure, const double, const double) |
void | paintPolygon (const vKisPoint &points) |
void | paintAt (const KisPoint &pos, const double pressure, const double, const double) |
void | setBrush (KisBrush *brush) |
KisBrush * | brush () const |
void | setPattern (KisPattern *pattern) |
KisPattern * | pattern () const |
void | setPaintColor (const KisColor &color) |
KisColor | paintColor () const |
void | setBackgroundColor (const KisColor &color) |
KisColor | backgroundColor () const |
void | setFillColor (const KisColor &color) |
KisColor | fillColor () const |
void | setFillStyle (FillStyle fillStyle) |
FillStyle | fillStyle () const |
void | setStrokeStyle (StrokeStyle strokeStyle) |
StrokeStyle | strokeStyle () const |
void | setOpacity (Q_UINT8 opacity) |
Q_UINT8 | opacity () const |
void | setCompositeOp (const KisCompositeOp &op) |
KisCompositeOp | compositeOp () const |
void | setFilter (KisFilterSP filter) |
KisFilterSP | filter () |
void | setDuplicateOffset (const KisPoint &offset) |
KisPoint | duplicateOffset () |
void | setDuplicateHealing (bool v) |
bool | duplicateHealing () |
void | setDuplicateHealingRadius (int r) |
int | duplicateHealingRadius () |
void | setDuplicatePerspectiveCorrection (bool v) |
bool | duplicatePerspectiveCorrection () |
void | setDuplicateStart (const KisPoint start) |
KisPoint | duplicateStart () |
void | setPressure (double pressure) |
double | pressure () |
void | setPaintOp (KisPaintOp *paintOp) |
KisPaintOp * | paintOp () const |
void | setDab (KisPaintDeviceSP dab) |
KisPaintDeviceSP | dab () const |
bool | cancelRequested () const |
Protected Member Functions | |
void | init () |
KisPainter (const KisPainter &) | |
KisPainter & | operator= (const KisPainter &) |
void | fillPolygon (const vKisPoint &points, FillStyle fillStyle) |
Static Protected Member Functions | |
static double | pointToLineDistance (const KisPoint &p, const KisPoint &l0, const KisPoint &l1) |
Protected Attributes | |
KisPaintDeviceSP | m_device |
KisTransaction * | m_transaction |
QRect | m_dirtyRect |
KisColor | m_paintColor |
KisColor | m_backgroundColor |
KisColor | m_fillColor |
FillStyle | m_fillStyle |
StrokeStyle | m_strokeStyle |
KisBrush * | m_brush |
KisPattern * | m_pattern |
KisPoint | m_duplicateOffset |
KisPoint | m_duplicateStart |
bool | m_duplicateHealing |
int | m_duplicateHealingRadius |
bool | m_duplicatePerspectiveCorrection |
Q_UINT8 | m_opacity |
KisCompositeOp | m_compositeOp |
KisFilterSP | m_filter |
KisPaintOp * | m_paintOp |
double | m_pressure |
bool | m_cancelRequested |
Q_INT32 | m_pixelSize |
KisColorSpace * | m_colorSpace |
KisProfile * | m_profile |
KisPaintDeviceSP | m_dab |
Member Enumeration Documentation
This enum contains the styles with which we can fill things like polygons and ellipses.
Definition at line 294 of file kis_painter.h.
Constructor & Destructor Documentation
KisPainter::KisPainter | ( | ) |
KisPainter::KisPainter | ( | KisPaintDeviceSP | device | ) |
Construct a painter, and begin painting on the device.
Definition at line 74 of file kis_painter.cc.
Member Function Documentation
void KisPainter::begin | ( | KisPaintDeviceSP | device | ) |
Start painting on the specified device.
Not undoable.
Definition at line 106 of file kis_painter.cc.
KCommand * KisPainter::end | ( | ) |
void KisPainter::beginTransaction | ( | const QString & | customName = QString::null |
) |
KCommand * KisPainter::endTransaction | ( | ) |
void KisPainter::beginTransaction | ( | KisTransaction * | command | ) |
KisTransaction* KisPainter::transaction | ( | ) | [inline] |
KisPaintDeviceSP KisPainter::device | ( | ) | const [inline] |
void KisPainter::bitBlt | ( | Q_INT32 | dx, | |
Q_INT32 | dy, | |||
const KisCompositeOp & | op, | |||
KisPaintDeviceSP | src, | |||
Q_INT32 | sx, | |||
Q_INT32 | sy, | |||
Q_INT32 | sw, | |||
Q_INT32 | sh | |||
) | [inline] |
Blast the specified region from src onto the current paint device.
Definition at line 105 of file kis_painter.h.
void KisPainter::bitBlt | ( | Q_INT32 | dx, | |
Q_INT32 | dy, | |||
const KisCompositeOp & | op, | |||
KisPaintDeviceSP | src, | |||
Q_UINT8 | opacity, | |||
Q_INT32 | sx, | |||
Q_INT32 | sy, | |||
Q_INT32 | sw, | |||
Q_INT32 | sh | |||
) |
Overloaded version of the previous, differs in that it is possible to specify a value for opacity.
Definition at line 153 of file kis_painter.cc.
void KisPainter::bltMask | ( | Q_INT32 | dx, | |
Q_INT32 | dy, | |||
const KisCompositeOp & | op, | |||
KisPaintDeviceSP | src, | |||
KisPaintDeviceSP | selMask, | |||
Q_UINT8 | opacity, | |||
Q_INT32 | sx, | |||
Q_INT32 | sy, | |||
Q_INT32 | sw, | |||
Q_INT32 | sh | |||
) |
A version of bitBlt that renders using an external mask, ignoring the src device's own selection, if it has one.
Definition at line 266 of file kis_painter.cc.
void KisPainter::bltSelection | ( | Q_INT32 | dx, | |
Q_INT32 | dy, | |||
const KisCompositeOp & | op, | |||
KisPaintDeviceSP | src, | |||
KisSelectionSP | selMask, | |||
Q_UINT8 | opacity, | |||
Q_INT32 | sx, | |||
Q_INT32 | sy, | |||
Q_INT32 | sw, | |||
Q_INT32 | sh | |||
) |
A version of bitBlt that renders using an external selection mask, ignoring the src device's own selection, if it has one.
Definition at line 243 of file kis_painter.cc.
void KisPainter::bltSelection | ( | Q_INT32 | dx, | |
Q_INT32 | dy, | |||
const KisCompositeOp & | op, | |||
KisPaintDeviceSP | src, | |||
Q_UINT8 | opacity, | |||
Q_INT32 | sx, | |||
Q_INT32 | sy, | |||
Q_INT32 | sw, | |||
Q_INT32 | sh | |||
) |
A version of bitBlt that renders using the src device's selection mask, if it has one.
Definition at line 370 of file kis_painter.cc.
QRect KisPainter::dirtyRect | ( | ) |
The methods below are 'higher' level than the above methods.
They need brushes, colors etc. set before they can be called. The methods do not directly tell the image to update, but you can call dirtyRect() to get the rect that needs to be notified by your painting code.
Call will RESET the dirtyRect!
Definition at line 147 of file kis_painter.cc.
QRect KisPainter::addDirtyRect | ( | QRect | r | ) | [inline] |
Add the r to the current dirty rect, and return the dirtyRect after adding r to it.
Definition at line 174 of file kis_painter.h.
void KisPainter::paintPolyline | ( | const QValueVector< KisPoint > & | points, | |
int | index = 0 , |
|||
int | numPoints = -1 | |||
) |
Paint a line that connects the dots in points.
double KisPainter::paintLine | ( | const KisPoint & | pos1, | |
const double | pressure1, | |||
const double | xTilt1, | |||
const double | yTilt1, | |||
const KisPoint & | pos2, | |||
const double | pressure2, | |||
const double | xTilt2, | |||
const double | yTilt2, | |||
const double | savedDist = -1 | |||
) |
Draw a line between pos1 and pos2 using the currently set brush and color.
If savedDist is less than zero, the brush is painted at pos1 before being painted along the line using the spacing setting.
- Returns:
- the drag distance, that is the remains of the distance between p1 and p2 not covered because the currenlty set brush has a spacing greater than that distance.
Definition at line 385 of file kis_painter.cc.
double KisPainter::paintBezierCurve | ( | const KisPoint & | pos1, | |
const double | pressure1, | |||
const double | xTilt1, | |||
const double | yTilt1, | |||
const KisPoint & | control1, | |||
const KisPoint & | control2, | |||
const KisPoint & | pos2, | |||
const double | pressure2, | |||
const double | xTilt2, | |||
const double | yTilt2, | |||
const double | savedDist = -1 | |||
) |
Draw a Bezier curve between pos1 and pos2 using control points 1 and 2.
If savedDist is less than zero, the brush is painted at pos1 before being painted along the curve using the spacing setting.
- Returns:
- the drag distance, that is the remains of the distance between p1 and p2 not covered because the currenlty set brush has a spacing greater than that distance.
Definition at line 538 of file kis_painter.cc.
void KisPainter::getBezierCurvePoints | ( | const KisPoint & | pos1, | |
const KisPoint & | control1, | |||
const KisPoint & | control2, | |||
const KisPoint & | pos2, | |||
vKisPoint & | points | |||
) |
Fill the given vector points with the points needed to draw the Bezier curve between pos1 and pos2 using control points 1 and 2, excluding the final pos2.
Definition at line 505 of file kis_painter.cc.
void KisPainter::paintPolygon | ( | const vKisPoint & | points | ) |
Paint the polygon with the points given in points.
It automatically closes the polygon by drawing the line from the last point to the first.
Definition at line 900 of file kis_painter.cc.
void KisPainter::paintAt | ( | const KisPoint & | pos, | |
const double | pressure, | |||
const | double, | |||
const | double | |||
) |
Draw a spot at pos using the currently set paint op, brush and color.
Definition at line 653 of file kis_painter.cc.
void KisPainter::setBrush | ( | KisBrush * | brush | ) | [inline] |
KisBrush* KisPainter::brush | ( | ) | const [inline] |
void KisPainter::setPattern | ( | KisPattern * | pattern | ) | [inline] |
KisPattern* KisPainter::pattern | ( | ) | const [inline] |
void KisPainter::setPaintColor | ( | const KisColor & | color | ) | [inline] |
KisColor KisPainter::paintColor | ( | ) | const [inline] |
void KisPainter::setBackgroundColor | ( | const KisColor & | color | ) | [inline] |
KisColor KisPainter::backgroundColor | ( | ) | const [inline] |
void KisPainter::setFillColor | ( | const KisColor & | color | ) | [inline] |
KisColor KisPainter::fillColor | ( | ) | const [inline] |
void KisPainter::setFillStyle | ( | FillStyle | fillStyle | ) | [inline] |
FillStyle KisPainter::fillStyle | ( | ) | const [inline] |
void KisPainter::setStrokeStyle | ( | StrokeStyle | strokeStyle | ) | [inline] |
StrokeStyle KisPainter::strokeStyle | ( | ) | const [inline] |
void KisPainter::setOpacity | ( | Q_UINT8 | opacity | ) | [inline] |
Set the opacity which is used in painting (like filling polygons).
Definition at line 320 of file kis_painter.h.
Q_UINT8 KisPainter::opacity | ( | ) | const [inline] |
void KisPainter::setCompositeOp | ( | const KisCompositeOp & | op | ) | [inline] |
Sets the current composite operation.
Everything painted will be composited on the destination layer with this composite op.
Definition at line 328 of file kis_painter.h.
KisCompositeOp KisPainter::compositeOp | ( | ) | const [inline] |
void KisPainter::setFilter | ( | KisFilterSP | filter | ) | [inline] |
Sets the current KisFilter, used by the paintops that support it (like KisFilterOp).
Definition at line 333 of file kis_painter.h.
KisFilterSP KisPainter::filter | ( | ) | [inline] |
void KisPainter::setDuplicateOffset | ( | const KisPoint & | offset | ) | [inline] |
The offset for paint operations that use it (like KisDuplicateOp).
It will use as source the part of the layer that is at its paintedPosition - duplicateOffset
Definition at line 342 of file kis_painter.h.
KisPoint KisPainter::duplicateOffset | ( | ) | [inline] |
void KisPainter::setPressure | ( | double | pressure | ) | [inline] |
Sets the current pressure for things that like to use this.
Definition at line 359 of file kis_painter.h.
double KisPainter::pressure | ( | ) | [inline] |
void KisPainter::setPaintOp | ( | KisPaintOp * | paintOp | ) | [inline] |
Set the current paint operation.
This is used for all drawing functions. The painter will DELETE the paint op itself!! That means no that you should not delete it yourself (or put it on the stack)
Definition at line 368 of file kis_painter.h.
KisPaintOp* KisPainter::paintOp | ( | ) | const [inline] |
void KisPainter::setDab | ( | KisPaintDeviceSP | dab | ) | [inline] |
Set a current 'dab'. This usually is a paint device containing a rendered brush.
Definition at line 373 of file kis_painter.h.
KisPaintDeviceSP KisPainter::dab | ( | ) | const [inline] |
bool KisPainter::cancelRequested | ( | ) | const [inline] |
Is cancel Requested by the KisProgressSubject for this painter.
Definition at line 378 of file kis_painter.h.
void KisPainter::init | ( | ) | [protected] |
double KisPainter::pointToLineDistance | ( | const KisPoint & | p, | |
const KisPoint & | l0, | |||
const KisPoint & | l1 | |||
) | [static, protected] |
Calculate the distance that point p is from the line made by connecting l0 and l1.
Definition at line 662 of file kis_painter.cc.
void KisPainter::fillPolygon | ( | const vKisPoint & | points, | |
FillStyle | fillStyle | |||
) | [protected] |
Fill the polygon defined by points with the fillStyle.
Definition at line 760 of file kis_painter.cc.
The documentation for this class was generated from the following files: