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 | |
FillStyleNone | |
FillStyleForegroundColor | |
FillStyleBackgroundColor | |
FillStylePattern | |
FillStyleGradient | |
FillStyleStrokes | |
StrokeStyleNone | |
StrokeStyleBrush | |
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 | 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 | 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 |
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 283 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
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 163 of file kis_painter.h.
KisColor KisPainter::backgroundColor | ( | ) | const [inline] |
void KisPainter::begin | ( | KisPaintDeviceSP | device | ) |
Start painting on the specified device.
Not undoable.
Definition at line 103 of file kis_painter.cc.
void KisPainter::beginTransaction | ( | KisTransaction * | command | ) |
void KisPainter::beginTransaction | ( | const QString & | customName = QString::null |
) |
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 150 of file kis_painter.cc.
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::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 344 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 236 of file kis_painter.cc.
KisBrush* KisPainter::brush | ( | ) | const [inline] |
bool KisPainter::cancelRequested | ( | ) | const [inline] |
Is cancel Requested by the KisProgressSubject for this painter.
Definition at line 354 of file kis_painter.h.
KisCompositeOp KisPainter::compositeOp | ( | ) | const [inline] |
KisPaintDeviceSP KisPainter::dab | ( | ) | const [inline] |
KisPaintDeviceSP KisPainter::device | ( | ) | const [inline] |
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 144 of file kis_painter.cc.
KisPoint KisPainter::duplicateOffset | ( | ) | [inline] |
KCommand * KisPainter::end | ( | ) |
KCommand * KisPainter::endTransaction | ( | ) |
KisColor KisPainter::fillColor | ( | ) | const [inline] |
void KisPainter::fillPolygon | ( | const vKisPoint & | points, | |
FillStyle | fillStyle | |||
) | [protected] |
Fill the polygon defined by points with the fillStyle.
Definition at line 734 of file kis_painter.cc.
FillStyle KisPainter::fillStyle | ( | ) | const [inline] |
KisFilterSP KisPainter::filter | ( | ) | [inline] |
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 479 of file kis_painter.cc.
void KisPainter::init | ( | ) | [protected] |
Q_UINT8 KisPainter::opacity | ( | ) | const [inline] |
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 627 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 512 of file kis_painter.cc.
KisColor KisPainter::paintColor | ( | ) | const [inline] |
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 359 of file kis_painter.cc.
KisPaintOp* KisPainter::paintOp | ( | ) | const [inline] |
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 874 of file kis_painter.cc.
void KisPainter::paintPolyline | ( | const QValueVector< KisPoint > & | points, | |
int | index = 0 , |
|||
int | numPoints = -1 | |||
) |
Paint a line that connects the dots in points.
KisPattern* KisPainter::pattern | ( | ) | const [inline] |
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 636 of file kis_painter.cc.
double KisPainter::pressure | ( | ) | [inline] |
void KisPainter::setBackgroundColor | ( | const KisColor & | color | ) | [inline] |
void KisPainter::setBrush | ( | KisBrush * | brush | ) | [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 317 of file kis_painter.h.
void KisPainter::setDab | ( | KisPaintDeviceSP | dab | ) | [inline] |
Set a current 'dab'. This usually is a paint device containing a rendered brush.
Definition at line 349 of file kis_painter.h.
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 330 of file kis_painter.h.
void KisPainter::setFillColor | ( | const KisColor & | color | ) | [inline] |
void KisPainter::setFillStyle | ( | FillStyle | fillStyle | ) | [inline] |
void KisPainter::setFilter | ( | KisFilterSP | filter | ) | [inline] |
Sets the current KisFilter, used by the paintops that support it (like KisFilterOp).
Definition at line 322 of file kis_painter.h.
void KisPainter::setOpacity | ( | Q_UINT8 | opacity | ) | [inline] |
Set the opacity which is used in painting (like filling polygons).
Definition at line 309 of file kis_painter.h.
void KisPainter::setPaintColor | ( | const KisColor & | color | ) | [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 344 of file kis_painter.h.
void KisPainter::setPattern | ( | KisPattern * | pattern | ) | [inline] |
void KisPainter::setPressure | ( | double | pressure | ) | [inline] |
Sets the current pressure for things that like to use this.
Definition at line 335 of file kis_painter.h.
void KisPainter::setStrokeStyle | ( | StrokeStyle | strokeStyle | ) | [inline] |
StrokeStyle KisPainter::strokeStyle | ( | ) | const [inline] |
KisTransaction* KisPainter::transaction | ( | ) | [inline] |
The documentation for this class was generated from the following files: