Krita Source Code Documentation
Loading...
Searching...
No Matches
ColorizeMask Class Reference

The ColorizeMask class A colorize mask is a mask type node that can be used to color in line art. More...

#include <ColorizeMask.h>

+ Inheritance diagram for ColorizeMask:

Public Slots

qreal cleanUpAmount () const
 cleanUpAmount
 
qreal edgeDetectionSize () const
 edgeDetectionSize
 
bool editKeyStrokes () const
 editKeyStrokes Edit keystrokes mode allows the user to modify keystrokes on the active Colorize Mask.
 
void initializeKeyStrokeColors (QList< ManagedColor * > colors, int transparentIndex=-1)
 initializeKeyStrokeColors Set the colors to use for the Colorize Mask's keystrokes.
 
QByteArray keyStrokePixelData (ManagedColor *color, int x, int y, int w, int h) const
 keyStrokePixelData reads the given rectangle from the keystroke image data and returns it as a byte array. The pixel data starts top-left, and is ordered row-first.
 
QList< ManagedColor * > keyStrokesColors () const
 keyStrokesColors Colors used in the Colorize Mask's keystrokes.
 
bool limitToDeviceBounds () const
 limitToDeviceBounds
 
void removeKeyStroke (ManagedColor *color)
 removeKeyStroke Remove a color from the Colorize Mask's keystrokes.
 
void resetCache ()
 
void setCleanUpAmount (qreal value)
 setCleanUpAmount This will attempt to handle messy strokes that overlap the line art where they shouldn't.
 
void setEdgeDetectionSize (qreal value)
 setEdgeDetectionSize Set the value to the thinnest line on the image.
 
void setEditKeyStrokes (bool enabled)
 setEditKeyStrokes Toggle Colorize Mask's edit keystrokes mode.
 
bool setKeyStrokePixelData (QByteArray value, ManagedColor *color, int x, int y, int w, int h)
 setKeyStrokePixelData writes the given bytes, of which there must be enough, into the keystroke, the keystroke's original pixels are overwritten
 
void setLimitToDeviceBounds (bool value)
 setLimitToDeviceBounds Limit the colorize mask to the combined layer bounds of the strokes and the line art it is filling. This can speed up the use of the mask on complicated compositions, such as comic pages.
 
void setShowOutput (bool enabled)
 setShowOutput Toggle Colorize Mask's show output mode.
 
void setUseEdgeDetection (bool value)
 setUseEdgeDetection Activate this for line art with large solid areas, for example shadows on an object.
 
bool showOutput () const
 showOutput Show output mode allows the user to see the result of the Colorize Mask's algorithm.
 
int transparencyIndex () const
 transparencyIndex Index of the transparent color.
 
virtual QString type () const override
 type Krita has several types of nodes, split in layers and masks. Group layers can contain other layers, any layer can contain masks.
 
void updateMask (bool force=false)
 updateMask Process the Colorize Mask's keystrokes and generate a projection of the computed colors.
 
bool useEdgeDetection () const
 useEdgeDetection
 
- Public Slots inherited from Node
bool addChildNode (Node *child, Node *above)
 addChildNode adds the given node in the list of children.
 
bool alphaLocked () const
 alphaLocked checks whether the node is a paint layer and returns whether it is alpha locked
 
bool animated () const
 Krita layers can be animated, i.e., have frames.
 
QString blendingMode () const
 
QRect bounds () const
 bounds return the exact bounds of the node's paint device
 
QList< Channel * > channels () const
 channels creates a list of Channel objects that can be used individually to show or hide certain channels, and to retrieve the contents of each channel in a node separately.
 
QList< Node * > childNodes () const
 childNodes
 
Nodeclone () const
 clone clone the current node. The node is not associated with any image.
 
bool collapsed () const
 
QString colorDepth () const
 
int colorLabel () const
 
QString colorModel () const
 colorModel retrieve the current color model of this document:
 
QString colorProfile () const
 
void cropNode (int x, int y, int w, int h)
 cropNode crop this layer.
 
Nodeduplicate ()
 duplicate returns a full copy of the current node. The node is not inserted in the graphic
 
void enableAnimation () const
 enableAnimation make the current layer animated, so it can have frames.
 
QList< Node * > findChildNodes (const QString &name=QString(), bool recursive=false, bool partialMatch=false, const QString &type=QString(), int colorLabelIndex=0) const
 findChildNodes
 
bool hasExtents ()
 does the node have any content in it?
 
bool hasKeyframeAtTime (int frameNumber)
 
QIcon icon () const
 icon
 
int index () const
 index the index of the node inside the parent
 
bool inheritAlpha () const
 inheritAlpha checks whether this node has the inherits alpha flag set
 
bool isPinnedToTimeline () const
 
QString layerStyleToAsl ()
 layerStyleToAsl retrieve the current layer's style in ASL format.
 
bool locked () const
 locked checks whether the Node is locked. A locked node cannot be changed.
 
NodemergeDown ()
 mergeDown merges the given node with the first visible node underneath this node in the layerstack. This will drop all per-layer metadata.
 
void move (int x, int y)
 
QString name () const
 
int opacity () const
 
QString paintAbility ()
 paintAbility can be used to determine whether this node can be painted on with the current brush preset.
 
void paintEllipse (const QRectF &rect, const QString strokeStyle=PaintingResources::defaultStrokeStyle, const QString fillStyle=PaintingResources::defaultFillStyle)
 paint an ellipse on the canvas. Uses current brush preset
 
void paintLine (const QPointF pointOne, const QPointF pointTwo, double pressureOne=1.0, double pressureTwo=1.0, const QString strokeStyle=PaintingResources::defaultStrokeStyle)
 paint a line on the canvas. Uses current brush preset
 
void paintPath (const QPainterPath &path, const QString strokeStyle=PaintingResources::defaultStrokeStyle, const QString fillStyle=PaintingResources::defaultFillStyle)
 paint a custom path on the canvas. Uses current brush preset
 
void paintPolygon (const QList< QPointF > points, const QString strokeStyle=PaintingResources::defaultStrokeStyle, const QString fillStyle=PaintingResources::defaultFillStyle)
 paint a polygon on the canvas. Uses current brush preset
 
void paintRectangle (const QRectF &rect, const QString strokeStyle=PaintingResources::defaultStrokeStyle, const QString fillStyle=PaintingResources::defaultFillStyle)
 paint a rectangle on the canvas. Uses current brush preset
 
NodeparentNode () const
 
QByteArray pixelData (int x, int y, int w, int h) const
 pixelData reads the given rectangle from the Node's paintable pixels, if those exist, and returns it as a byte array. The pixel data starts top-left, and is ordered row-first.
 
QByteArray pixelDataAtTime (int x, int y, int w, int h, int time) const
 pixelDataAtTime a basic function to get pixeldata from an animated node at a given time.
 
QPoint position () const
 position returns the position of the paint device of this node. The position is always 0,0 unless the layer has been moved. If you want to know the topleft position of the rectangle around the actual non-transparent pixels in the node, use bounds().
 
QByteArray projectionPixelData (int x, int y, int w, int h) const
 projectionPixelData reads the given rectangle from the Node's projection (that is, what the node looks like after all sub-Nodes (like layers in a group or masks on a layer) have been applied, and returns it as a byte array. The pixel data starts top-left, and is ordered row-first.
 
bool remove ()
 remove removes this node from its parent image.
 
bool removeChildNode (Node *child)
 removeChildNode removes the given node from the list of children.
 
void rotateNode (double radians)
 rotateNode rotate this layer by the given radians.
 
bool save (const QString &filename, double xRes, double yRes, const InfoObject &exportConfiguration, const QRect &exportRect=QRect())
 save exports the given node with this filename. The extension of the filename determines the filetype.
 
void scaleNode (QPointF origin, int width, int height, QString strategy)
 scaleNode
 
void setAlphaLocked (bool value)
 setAlphaLocked set the layer to value if the node is paint layer.
 
void setBlendingMode (QString value)
 setBlendingMode set the blending mode of the node to the given value
 
void setChildNodes (QList< Node * > nodes)
 setChildNodes this replaces the existing set of child nodes with the new set.
 
void setCollapsed (bool collapsed)
 
void setColorLabel (int index)
 setColorLabel sets a color label index associated to the layer. The actual color of the label and the number of available colors is defined by Krita GUI configuration.
 
bool setColorProfile (const QString &colorProfile)
 setColorProfile set the color profile of the image to the given profile. The profile has to be registered with krita and be compatible with the current color model and depth; the image data is not converted.
 
bool setColorSpace (const QString &colorModel, const QString &colorDepth, const QString &colorProfile)
 setColorSpace convert the node to the given colorspace
 
void setInheritAlpha (bool value)
 
bool setLayerStyleFromAsl (const QString &asl)
 setLayerStyleFromAsl set a new layer style for this node.
 
void setLocked (bool value)
 
void setName (QString name)
 
void setOpacity (int value)
 
void setPinnedToTimeline (bool pinned) const
 Sets whether or not node should be pinned to the Timeline Docker, regardless of selection activity.
 
bool setPixelData (QByteArray value, int x, int y, int w, int h)
 setPixelData writes the given bytes, of which there must be enough, into the Node, if the Node has writable pixel data:
 
void setVisible (bool visible)
 
void shearNode (double angleX, double angleY)
 shearNode perform a shear operation on this node.
 
QImage thumbnail (int w, int h)
 thumbnail create a thumbnail of the given dimensions. The thumbnail is sized according to the layer dimensions, not the image dimensions. If the requested size is too big a null QImage is created. If the current node cannot generate a thumbnail, a transparent QImage of the requested size is generated.
 
virtual QString type () const
 type Krita has several types of nodes, split in layers and masks. Group layers can contain other layers, any layer can contain masks.
 
QUuid uniqueId () const
 uniqueId uniqueId of the node
 
bool visible () const
 

Public Member Functions

 ColorizeMask (KisImageSP image, KisColorizeMaskSP mask, QObject *parent=0)
 
 ColorizeMask (KisImageSP image, QString name, QObject *parent=0)
 
 ~ColorizeMask () override
 
- Public Member Functions inherited from Node
bool operator!= (const Node &other) const
 
bool operator== (const Node &other) const
 
 ~Node () override
 

Additional Inherited Members

- Static Public Member Functions inherited from Node
static NodecreateNode (KisImageSP image, KisNodeSP node, QObject *parent=0)
 

Detailed Description

The ColorizeMask class A colorize mask is a mask type node that can be used to color in line art.

doc = Krita.instance().createDocument(10, 3, "Test", "RGBA", "U8", "", 120.0)
window.addView(doc)
root = doc.rootNode();
node = doc.createNode("layer", "paintLayer")
root.addChildNode(node, None)
nodeData = QByteArray.fromBase64(b"AAAAAAAAAAAAAAAAEQYMBhEGDP8RBgz/EQYMAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARBgz5EQYM/xEGDAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQYMAhEGDAkRBgwCAAAAAAAAAAAAAAAA");
node.setPixelData(nodeData,0,0,10,3)
cols = [ ManagedColor('RGBA','U8',''), ManagedColor('RGBA','U8','') ]
cols[0].setComponents([0.65490198135376, 0.345098048448563, 0.474509805440903, 1.0]);
cols[1].setComponents([0.52549022436142, 0.666666686534882, 1.0, 1.0]);
keys = [
QByteArray.fromBase64(b"/48AAAAAAAAAAAAAAAAAAAAAAACmCwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"),
QByteArray.fromBase64(b"AAAAAAAAAACO9ocAAAAAAAAAAAAAAAAAAAAAAMD/uQAAAAAAAAAAAAAAAAAAAAAAGoMTAAAAAAAAAAAA")
]
mask = doc.createColorizeMask('c1')
node.addChildNode(mask,None)
mask.setEditKeyStrokes(True)
mask.setUseEdgeDetection(True)
mask.setEdgeDetectionSize(4.0)
mask.setCleanUpAmount(70.0)
mask.setLimitToDeviceBounds(True)
mask.initializeKeyStrokeColors(cols)
for col,key in zip(cols,keys):
mask.setKeyStrokePixelData(key,col,0,0,20,3)
mask.updateMask()
mask.setEditKeyStrokes(False);
mask.setShowOutput(True);
void setEditKeyStrokes(bool enabled)
setEditKeyStrokes Toggle Colorize Mask's edit keystrokes mode.
bool setKeyStrokePixelData(QByteArray value, ManagedColor *color, int x, int y, int w, int h)
setKeyStrokePixelData writes the given bytes, of which there must be enough, into the keystroke,...
void updateMask(bool force=false)
updateMask Process the Colorize Mask's keystrokes and generate a projection of the computed colors.
Node * rootNode() const
rootNode the root node is the invisible group layer that contains the entire node hierarchy.
Definition Document.cpp:346
Definition Krita.h:28
static Krita * instance()
instance retrieve the singleton instance of the Application object.
Definition Krita.cpp:390
Document * createDocument(int width, int height, const QString &name, const QString &colorModel, const QString &colorDepth, const QString &profile, double resolution)
Definition Krita.cpp:317
Window * activeWindow() const
Definition Krita.cpp:233
The ManagedColor class is a class to handle colors that are color managed. A managed color is a color...
KisNodeSP node() const
Definition Node.cpp:827

Definition at line 59 of file ColorizeMask.h.

Constructor & Destructor Documentation

◆ ColorizeMask() [1/2]

ColorizeMask::ColorizeMask ( KisImageSP image,
QString name,
QObject * parent = 0 )
explicit

Definition at line 21 of file ColorizeMask.cpp.

21 :
22 Node(image, new KisColorizeMask(image,name), parent)
23{
24
25}
Node(KisImageSP image, KisNodeSP node, QObject *parent=0)
Definition Node.cpp:83
KisImageSP image() const
Definition Node.cpp:822
QString name() const
Definition Node.cpp:428

◆ ColorizeMask() [2/2]

ColorizeMask::ColorizeMask ( KisImageSP image,
KisColorizeMaskSP mask,
QObject * parent = 0 )
explicit

Definition at line 27 of file ColorizeMask.cpp.

27 :
28 Node(image, mask, parent)
29{
30}

◆ ~ColorizeMask()

ColorizeMask::~ColorizeMask ( )
override

Definition at line 32 of file ColorizeMask.cpp.

33{
34
35}

Member Function Documentation

◆ cleanUpAmount

qreal ColorizeMask::cleanUpAmount ( ) const
slot

cleanUpAmount

Returns
a float value of 0.0 to 100.0 representing the cleanup amount where 0.0 is no cleanup is done and 100.00 is most aggressive.

Definition at line 195 of file ColorizeMask.cpp.

196{
197 const KisColorizeMask *mask = qobject_cast<const KisColorizeMask*>(this->node());
199
200 return mask->cleanUpAmount();
201}
qreal cleanUpAmount() const
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129

References KisColorizeMask::cleanUpAmount(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, and Node::node().

◆ edgeDetectionSize

qreal ColorizeMask::edgeDetectionSize ( ) const
slot

edgeDetectionSize

Returns
a float value of the edge detection size in pixels.

Definition at line 179 of file ColorizeMask.cpp.

180{
181 const KisColorizeMask *mask = qobject_cast<const KisColorizeMask*>(this->node());
183
184 return mask->edgeDetectionSize();
185}
qreal edgeDetectionSize() const

References KisColorizeMask::edgeDetectionSize(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, and Node::node().

◆ editKeyStrokes

bool ColorizeMask::editKeyStrokes ( ) const
slot

editKeyStrokes Edit keystrokes mode allows the user to modify keystrokes on the active Colorize Mask.

Returns
true if edit keystrokes mode is enabled, false if disabled.

Definition at line 271 of file ColorizeMask.cpp.

272{
273 const KisColorizeMask *mask = qobject_cast<const KisColorizeMask*>(this->node());
275
277
278 for (const KisBaseNode::Property &prop : props) {
280 return prop.state.toBool();
281 }
282 }
283
284 return false;
285}
KisBaseNode::PropertyList sectionModelProperties() const override
QString id() const
Definition KoID.cpp:63

References KisLayerPropertiesIcons::colorizeEditKeyStrokes, KoID::id(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, Node::node(), and KisColorizeMask::sectionModelProperties().

◆ initializeKeyStrokeColors

void ColorizeMask::initializeKeyStrokeColors ( QList< ManagedColor * > colors,
int transparentIndex = -1 )
slot

initializeKeyStrokeColors Set the colors to use for the Colorize Mask's keystrokes.

Parameters
colorsa list of ManagedColor to use for the keystrokes.
transparentIndexindex of the color that should be marked as transparent.

This method is supposed to to initial initialization only!

It is necessary because the function also changes the color space and blending mode of the mask

TODO: implement a proper API that modifies key strokes of a colorize mask without breaking undo history

Definition at line 51 of file ColorizeMask.cpp.

52{
53 KisColorizeMaskSP mask = qobject_cast<KisColorizeMask*>(this->node().data());
55
66
68 delete mask->setColorSpace(mask->parent()->colorSpace());
69
71
72 for (int i = 0; i < colors.size(); i++) {
74 keyStroke.color = colors[i]->color();
75 keyStroke.dev = new KisPaintDevice(KoColorSpaceRegistry::instance()->alpha8());
76 keyStroke.dev->setDefaultBounds(new KisDefaultBounds(this->node()->image()));
77 keyStroke.isTransparent = transparentIndex == i;
78 // NOTE: the parent node link is initialized in
79 // setKeyStrokesDirect
80
81 keyStrokes.append(keyStroke);
82 }
83
84 mask->setKeyStrokesDirect(keyStrokes);
85}
void setKeyStrokesDirect(const QList< KisLazyFillTools::KeyStroke > &strokes)
KUndo2Command * setColorSpace(const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags(), KoUpdater *progressUpdater=nullptr)
KeyStrokeColors keyStrokesColors() const
void setDefaultBounds(KisDefaultBoundsBaseSP bounds)
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
virtual const KoColorSpace * colorSpace() const =0
KisNodeWSP parent
Definition kis_node.cpp:86
static KoColorSpaceRegistry * instance()

References KisLazyFillTools::KeyStroke::color, KisColorizeMask::KeyStrokeColors::colors, KisBaseNode::colorSpace(), KisLazyFillTools::KeyStroke::dev, Node::image(), KisColorizeMask::initializeCompositeOp(), KoColorSpaceRegistry::instance(), KisLazyFillTools::KeyStroke::isTransparent, KisColorizeMask::keyStrokesColors(), KIS_SAFE_ASSERT_RECOVER_RETURN, Node::node(), KisNode::parent, KisColorizeMask::setColorSpace(), KisPaintDevice::setDefaultBounds(), and KisColorizeMask::setKeyStrokesDirect().

◆ keyStrokePixelData

QByteArray ColorizeMask::keyStrokePixelData ( ManagedColor * color,
int x,
int y,
int w,
int h ) const
slot

keyStrokePixelData reads the given rectangle from the keystroke image data and returns it as a byte array. The pixel data starts top-left, and is ordered row-first.

Parameters
colora ManagedColor to get keystrokes pixeldata from.
xx position from where to start reading
yy position from where to start reading
wrow length to read
hnumber of rows to read
Returns
a QByteArray with the pixel data. The byte array may be empty.

Definition at line 105 of file ColorizeMask.cpp.

106{
107 QByteArray ba;
108
109 if (!this->node()) return ba;
110
111 const KoColor kc = color->color();
112 const KisColorizeMask *mask = qobject_cast<const KisColorizeMask*>(this->node());
113 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(mask, QByteArray());
114
115 for (KisLazyFillTools::KeyStroke keystroke : mask->fetchKeyStrokesDirect()) {
116 if (kc == keystroke.color) {
117 KisPaintDeviceSP dev = keystroke.dev;
118
119 if (!dev) return ba;
120
121 ba.resize(w * h * dev->pixelSize());
122 dev->readBytes(reinterpret_cast<quint8*>(ba.data()), x, y, w, h);
123 return ba;
124 }
125 }
126
127 return ba;
128}
quint32 pixelSize() const
void readBytes(quint8 *data, qint32 x, qint32 y, qint32 w, qint32 h) const
KoColor color() const

References ManagedColor::color(), KisColorizeMask::fetchKeyStrokesDirect(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, Node::node(), KisPaintDevice::pixelSize(), and KisPaintDevice::readBytes().

◆ keyStrokesColors

QList< ManagedColor * > ColorizeMask::keyStrokesColors ( ) const
slot

keyStrokesColors Colors used in the Colorize Mask's keystrokes.

Returns
a ManagedColor list containing the colors of keystrokes.

Definition at line 38 of file ColorizeMask.cpp.

39{
40 QList<ManagedColor*> colorList;
41 const KisColorizeMask *mask = qobject_cast<const KisColorizeMask*>(this->node());
43
44 for (KoColor color : mask->keyStrokesColors().colors) {
45 colorList.append(new ManagedColor(color));
46 }
47
48 return colorList;
49}
QList< ManagedColor * > keyStrokesColors() const
keyStrokesColors Colors used in the Colorize Mask's keystrokes.

References KisColorizeMask::KeyStrokeColors::colors, KisColorizeMask::keyStrokesColors(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, and Node::node().

◆ limitToDeviceBounds

bool ColorizeMask::limitToDeviceBounds ( ) const
slot

limitToDeviceBounds

Returns
true if limit bounds is enabled, false if disabled.

Definition at line 211 of file ColorizeMask.cpp.

212{
213 const KisColorizeMask *mask = qobject_cast<const KisColorizeMask*>(this->node());
215
216 return mask->limitToDeviceBounds();
217}
bool limitToDeviceBounds() const

References KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, KisColorizeMask::limitToDeviceBounds(), and Node::node().

◆ removeKeyStroke

void ColorizeMask::removeKeyStroke ( ManagedColor * color)
slot

removeKeyStroke Remove a color from the Colorize Mask's keystrokes.

Parameters
colora ManagedColor to be removed from the keystrokes.

Definition at line 96 of file ColorizeMask.cpp.

97{
98 const KoColor kc = color->color();
99 KisColorizeMask *mask = qobject_cast<KisColorizeMask*>(this->node().data());
101
102 mask->removeKeyStroke(kc);
103}
void removeKeyStroke(const KoColor &color)

References ManagedColor::color(), KIS_SAFE_ASSERT_RECOVER_RETURN, Node::node(), and KisColorizeMask::removeKeyStroke().

◆ resetCache

void ColorizeMask::resetCache ( )
slot

Definition at line 231 of file ColorizeMask.cpp.

232{
233 KisColorizeMask *mask = qobject_cast<KisColorizeMask*>(this->node().data());
235
236 mask->resetCache();
237}

References KIS_SAFE_ASSERT_RECOVER_RETURN, Node::node(), and KisColorizeMask::resetCache().

◆ setCleanUpAmount

void ColorizeMask::setCleanUpAmount ( qreal value)
slot

setCleanUpAmount This will attempt to handle messy strokes that overlap the line art where they shouldn't.

Parameters
valuea float value from 0.0 to 100.00 where 0.0 is no cleanup is done and 100.00 is most aggressive.

Definition at line 187 of file ColorizeMask.cpp.

188{
189 KisColorizeMask *mask = qobject_cast<KisColorizeMask*>(this->node().data());
191
192 mask->setCleanUpAmount(value);
193}
float value(const T *src, size_t ch)
void setCleanUpAmount(qreal value)

References KIS_SAFE_ASSERT_RECOVER_RETURN, Node::node(), KisColorizeMask::setCleanUpAmount(), and value().

◆ setEdgeDetectionSize

void ColorizeMask::setEdgeDetectionSize ( qreal value)
slot

setEdgeDetectionSize Set the value to the thinnest line on the image.

Parameters
valuea float value of the edge size to detect in pixels.

Definition at line 171 of file ColorizeMask.cpp.

172{
173 KisColorizeMask *mask = qobject_cast<KisColorizeMask*>(this->node().data());
175
177}
void setEdgeDetectionSize(qreal value)

References KIS_SAFE_ASSERT_RECOVER_RETURN, Node::node(), KisColorizeMask::setEdgeDetectionSize(), and value().

◆ setEditKeyStrokes

void ColorizeMask::setEditKeyStrokes ( bool enabled)
slot

setEditKeyStrokes Toggle Colorize Mask's edit keystrokes mode.

Parameters
enabledset true to enable edit keystrokes mode and false to disable it.

Definition at line 263 of file ColorizeMask.cpp.

264{
265 KisColorizeMask *mask = qobject_cast<KisColorizeMask*>(this->node().data());
267
269}
static void setNodePropertyAutoUndo(KisNodeSP node, const KoID &id, const QVariant &value, KisImageSP image)

References KisLayerPropertiesIcons::colorizeEditKeyStrokes, Node::image(), KIS_SAFE_ASSERT_RECOVER_RETURN, Node::node(), and KisLayerPropertiesIcons::setNodePropertyAutoUndo().

◆ setKeyStrokePixelData

bool ColorizeMask::setKeyStrokePixelData ( QByteArray value,
ManagedColor * color,
int x,
int y,
int w,
int h )
slot

setKeyStrokePixelData writes the given bytes, of which there must be enough, into the keystroke, the keystroke's original pixels are overwritten

Parameters
valuethe byte array representing the pixels. There must be enough bytes available. Krita will take the raw pointer from the QByteArray and start reading, not stopping before (number of channels * size of channel * w * h) bytes are read.
colora ManagedColor to set keystrokes pixeldata for.
xthe x position to start writing from
ythe y position to start writing from
wthe width of each row
hthe number of rows to write
Returns
true if writing the pixeldata worked

Definition at line 130 of file ColorizeMask.cpp.

131{
132 if (!this->node()) return false;
133
134 const KoColor kc = color->color();
135 const KisColorizeMask *mask = qobject_cast<const KisColorizeMask*>(this->node());
137
138 for (KisLazyFillTools::KeyStroke keystroke : mask->fetchKeyStrokesDirect()) {
139 if (kc == keystroke.color) {
140 KisPaintDeviceSP dev = keystroke.dev;
141
142 if (!dev) return false;
143 if (value.length() < w * h * (int)dev->colorSpace()->pixelSize()) {
144 qWarning() << "ColorizeMask::setKeyStrokePixelData: not enough data to write to the paint device";
145 return false;
146 }
147 dev->writeBytes((const quint8*)value.constData(), x, y, w, h);
148 return true;
149 }
150 }
151
152 return false;
153}
const KoColorSpace * colorSpace() const
void writeBytes(const quint8 *data, qint32 x, qint32 y, qint32 w, qint32 h)
virtual quint32 pixelSize() const =0

References ManagedColor::color(), KisPaintDevice::colorSpace(), KisColorizeMask::fetchKeyStrokesDirect(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, Node::node(), KoColorSpace::pixelSize(), value(), and KisPaintDevice::writeBytes().

◆ setLimitToDeviceBounds

void ColorizeMask::setLimitToDeviceBounds ( bool value)
slot

setLimitToDeviceBounds Limit the colorize mask to the combined layer bounds of the strokes and the line art it is filling. This can speed up the use of the mask on complicated compositions, such as comic pages.

Parameters
valueset true to enabled limit bounds, false to disable.

Definition at line 203 of file ColorizeMask.cpp.

204{
205 KisColorizeMask *mask = qobject_cast<KisColorizeMask*>(this->node().data());
207
209}
void setLimitToDeviceBounds(bool value)

References KIS_SAFE_ASSERT_RECOVER_RETURN, Node::node(), KisColorizeMask::setLimitToDeviceBounds(), and value().

◆ setShowOutput

void ColorizeMask::setShowOutput ( bool enabled)
slot

setShowOutput Toggle Colorize Mask's show output mode.

Parameters
enabledset true to enable show coloring mode and false to disable it.

Definition at line 239 of file ColorizeMask.cpp.

240{
241 KisColorizeMask *mask = qobject_cast<KisColorizeMask*>(this->node().data());
243
245}

References KisLayerPropertiesIcons::colorizeShowColoring, Node::image(), KIS_SAFE_ASSERT_RECOVER_RETURN, Node::node(), and KisLayerPropertiesIcons::setNodePropertyAutoUndo().

◆ setUseEdgeDetection

void ColorizeMask::setUseEdgeDetection ( bool value)
slot

setUseEdgeDetection Activate this for line art with large solid areas, for example shadows on an object.

Parameters
valuetrue to enable edge detection, false to disable.

Definition at line 155 of file ColorizeMask.cpp.

156{
157 KisColorizeMask *mask = qobject_cast<KisColorizeMask*>(this->node().data());
159
161}
void setUseEdgeDetection(bool value)

References KIS_SAFE_ASSERT_RECOVER_RETURN, Node::node(), KisColorizeMask::setUseEdgeDetection(), and value().

◆ showOutput

bool ColorizeMask::showOutput ( ) const
slot

showOutput Show output mode allows the user to see the result of the Colorize Mask's algorithm.

Returns
true if edit show coloring mode is enabled, false if disabled.

Definition at line 247 of file ColorizeMask.cpp.

248{
249 const KisColorizeMask *mask = qobject_cast<const KisColorizeMask*>(this->node());
251
253
254 for (const KisBaseNode::Property &prop : props) {
256 return prop.state.toBool();
257 }
258 }
259
260 return false;
261}

References KisLayerPropertiesIcons::colorizeShowColoring, KoID::id(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, Node::node(), and KisColorizeMask::sectionModelProperties().

◆ transparencyIndex

int ColorizeMask::transparencyIndex ( ) const
slot

transparencyIndex Index of the transparent color.

Returns
an integer containing the index of the current color marked as transparent.

Definition at line 88 of file ColorizeMask.cpp.

89{
90 const KisColorizeMask *mask = qobject_cast<const KisColorizeMask*>(this->node());
92
94}

References KisColorizeMask::keyStrokesColors(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, Node::node(), and KisColorizeMask::KeyStrokeColors::transparentIndex.

◆ type

QString ColorizeMask::type ( ) const
overridevirtualslot

type Krita has several types of nodes, split in layers and masks. Group layers can contain other layers, any layer can contain masks.

Returns
colorizemask

If the Node object isn't wrapping a valid Krita layer or mask object, and empty string is returned.

Definition at line 287 of file ColorizeMask.cpp.

288{
289 return "colorizemask";
290}

◆ updateMask

void ColorizeMask::updateMask ( bool force = false)
slot

updateMask Process the Colorize Mask's keystrokes and generate a projection of the computed colors.

Parameters
forceforce an update

Definition at line 219 of file ColorizeMask.cpp.

220{
221 KisColorizeMask *mask = qobject_cast<KisColorizeMask*>(this->node().data());
223
224 if (force) {
225 mask->forceRegenerateMask();
226 } else {
228 }
229}

References KisLayerPropertiesIcons::colorizeNeedsUpdate, KisColorizeMask::forceRegenerateMask(), Node::image(), KIS_SAFE_ASSERT_RECOVER_RETURN, Node::node(), and KisLayerPropertiesIcons::setNodePropertyAutoUndo().

◆ useEdgeDetection

bool ColorizeMask::useEdgeDetection ( ) const
slot

useEdgeDetection

Returns
true if Edge detection is enabled, false if disabled.

Definition at line 163 of file ColorizeMask.cpp.

164{
165 const KisColorizeMask *mask = qobject_cast<const KisColorizeMask*>(this->node());
167
168 return mask->useEdgeDetection();
169}
bool useEdgeDetection() const

References KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, Node::node(), and KisColorizeMask::useEdgeDetection().


The documentation for this class was generated from the following files: