Node represents a layer or mask in a Krita image's Node hierarchy. Group layers can contain other layers and masks; layers can contain masks.
Methods
Re-implemented methods
Member documentation
adds the given node in the list of children.
Parameters
child | the node to be added |
above | the node above which this node will be placed |
Return
false if adding the node failed |
checks whether the node is a paint layer and returns whether it is alpha locked
Return
whether the paint layer is alpha locked, or false if the node is not a paint layer |
Krita layers can be animated, i.e., have frames.
Return
return true if the layer has frames. Currently, the scripting framework does not give access to the animation features. |
Return
the blending mode of the layer. The values of the blending modes are defined in @see KoCompositeOpRegistry.h |
return the exact bounds of the node's paint device
Return
the bounds, or an empty QRect if the node has no paint device or is empty. |
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.
Only layers have channels, masks do not, and calling channels on a Node that is a mask will return an empty list.
Return
the list of channels ordered in by position of the channels in pixel position |
Return
returns a list of child nodes of the current node. The nodes are ordered from the bottommost up. The function is not recursive. |
clone the current node. The node is not associated with any image.
Return
(no description provided) |
returns the collapsed state of this node
Return
(no description provided) |
colorDepth A string describing the color depth of the image:
- U8: unsigned 8 bits integer, the most common type
- U16: unsigned 16 bits integer
- F16: half, 16 bits floating point. Only available if Krita was built with OpenEXR
- F32: 32 bits floating point
Return
the color depth. |
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.
Return
(no description provided) |
retrieve the current color model of this document:
- A: Alpha mask
- RGBA: RGB with alpha channel (The actual order of channels is most often BGR!)
- XYZA: XYZ with alpha channel
- LABA: LAB with alpha channel
- CMYKA: CMYK with alpha channel
- GRAYA: Gray with alpha channel
- YCbCrA: YCbCr with alpha channel
Return
the internal color model string. |
crop this layer.
Parameters
x | the left edge of the cropping rectangle. |
y | the top edge of the cropping rectangle |
w | the right edge of the cropping rectangle |
h | the bottom edge of the cropping rectangle |
returns a full copy of the current node. The node is not inserted in the graphic
Return
a valid Node object or 0 if the node couldn't be duplicated. |
Parameters
name | name of the child node to search for. Leaving this blank will return all nodes. |
recursive | whether or not to search recursively. Defaults to false. |
partialMatch | return if the name partially contains the string (case insensitive). Defaults to false. |
type | filter returned nodes based on type |
colorLabelIndex | filter returned nodes based on color label index |
Return
returns a list of child nodes and grand child nodes of the current node that match the search criteria. |
does the node have any content in it?
Return
if node has any content in it |
Check to see if frame number on layer is a keyframe
Parameters
frameNumber | (no description provided) |
Return
(no description provided) |
the index of the node inside the parent
Return
an integer representing the node's index inside the parent |
checks whether this node has the inherits alpha flag set
Return
true if the Inherit Alpha is set |
Return
Returns true if node is pinned to the Timeline Docker or false if it is not. |
retrieve the current layer's style in ASL format.
Return
a QString in ASL format representing the layer style. |
checks whether the Node is locked. A locked node cannot be changed.
Return
true if the Node is locked, false if it hasn't been locked. |
merges the given node with the first visible node underneath this node in the layerstack. This will drop all per-layer metadata.
Return
(no description provided) |
move the pixels to the given x, y location in the image coordinate space.
Parameters
x | (no description provided) |
y | (no description provided) |
return the opacity of the Node. The opacity is a value between 0 and 255.
Return
(no description provided) |
can be used to determine whether this node can be painted on with the current brush preset.
Return
QString, one of the following:
|
paint an ellipse on the canvas. Uses current brush preset
Parameters
rect | QRect with x, y, width, and height
|
strokeStyle | (no description provided) |
fillStyle | appearance of the fill, one of:
|
paint a line on the canvas. Uses current brush preset
Parameters
pointOne | starting point |
pointTwo | end point |
pressureOne | starting pressure |
pressureTwo | end pressure |
strokeStyle | appearance of the outline, one of:
|
paint a custom path on the canvas. Uses current brush preset
Parameters
path | (no description provided) |
strokeStyle | (no description provided) |
fillStyle | appearance of the fill, one of:
|
paint a polygon on the canvas. Uses current brush preset
Parameters
points | (no description provided) |
strokeStyle | (no description provided) |
fillStyle | appearance of the fill, one of:
|
paint a rectangle on the canvas. Uses current brush preset
Parameters
rect | QRect with x, y, width, and height |
strokeStyle | appearance of the outline, one of:
|
fillStyle | appearance of the fill, one of:
|
return the Node that is the parent of the current Node, or 0 if this is the root Node.
Return
(no description provided) |
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.
The byte array can be interpreted as follows: 8 bits images have one byte per channel, and as many bytes as there are channels. 16 bits integer images have two bytes per channel, representing an unsigned short. 16 bits float images have two bytes per channel, representing a half, or 16 bits float. 32 bits float images have four bytes per channel, representing a float.
You can read outside the node boundaries; those pixels will be transparent black.
The order of channels is:
- Integer RGBA: Blue, Green, Red, Alpha
- Float RGBA: Red, Green, Blue, Alpha
- GrayA: Gray, Alpha
- Selection: selectedness
- LabA: L, a, b, Alpha
- CMYKA: Cyan, Magenta, Yellow, Key, Alpha
- XYZA: X, Y, Z, A
- YCbCrA: Y, Cb, Cr, Alpha
The byte array is a copy of the original node data. In Python, you can use bytes, bytearray and the struct module to interpret the data and construct, for instance, a Pillow Image object.
If you read the pixeldata of a mask, a filter or generator layer, you get the selection bytes, which is one channel with values in the range from 0..255.
If you want to change the pixels of a node you can write the pixels back after manipulation with setPixelData(). This will only succeed on nodes with writable pixel data, e.g not on groups or file layers.
Parameters
x | x position from where to start reading |
y | y position from where to start reading |
w | row length to read |
h | number of rows to read |
Return
a QByteArray with the pixel data. The byte array may be empty. |
a basic function to get pixeldata from an animated node at a given time.
Parameters
x | the position from the left to start reading. |
y | the position from the top to start reader |
w | the row length to read |
h | the number of rows to read |
time | the frame number |
Return
a QByteArray with the pixel data. The byte array may be empty. |
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().
Return
the top-left position of the node |
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.
The byte array can be interpreted as follows: 8 bits images have one byte per channel, and as many bytes as there are channels. 16 bits integer images have two bytes per channel, representing an unsigned short. 16 bits float images have two bytes per channel, representing a half, or 16 bits float. 32 bits float images have four bytes per channel, representing a float.
You can read outside the node boundaries; those pixels will be transparent black.
The order of channels is:
- Integer RGBA: Blue, Green, Red, Alpha
- Float RGBA: Red, Green, Blue, Alpha
- GrayA: Gray, Alpha
- Selection: selectedness
- LabA: L, a, b, Alpha
- CMYKA: Cyan, Magenta, Yellow, Key, Alpha
- XYZA: X, Y, Z, A
- YCbCrA: Y, Cb, Cr, Alpha
The byte array is a copy of the original node data. In Python, you can use bytes, bytearray and the struct module to interpret the data and construct, for instance, a Pillow Image object.
If you read the projection of a mask, you get the selection bytes, which is one channel with values in the range from 0..255.
If you want to change the pixels of a node you can write the pixels back after manipulation with setPixelData(). This will only succeed on nodes with writable pixel data, e.g not on groups or file layers.
Parameters
x | x position from where to start reading |
y | y position from where to start reading |
w | row length to read |
h | number of rows to read |
Return
a QByteArray with the pixel data. The byte array may be empty. |
removes this node from its parent image.
Return
(no description provided) |
removes the given node from the list of children.
Parameters
child | the node to be removed |
Return
(no description provided) |
rotate this layer by the given radians.
Parameters
radians | amount the layer should be rotated in, in radians. |
exports the given node with this filename. The extension of the filename determines the filetype.
Parameters
filename | the filename including extension |
xRes | the horizontal resolution in pixels per pt (there are 72 pts in an inch) |
yRes | the horizontal resolution in pixels per pt (there are 72 pts in an inch) |
exportConfiguration | a configuration object appropriate to the file format. |
exportRect | the export bounds for saving a node as a QRect If \p exportRect is empty, then save exactBounds() of the node. If you'd like to save the image- aligned area of the node, just pass image->bounds() there. See Document->exportImage for InfoObject details. |
Return
true if saving succeeded, false if it failed. |
Parameters
origin | the origin point |
width | the width |
height | the height |
strategy | the scaling strategy. There's several ones amongst these that aren't available in the regular UI.
|
set the layer to value if the node is paint layer.
Parameters
value | (no description provided) |
set the blending mode of the node to the given value
Parameters
value | one of the string values from @see KoCompositeOpRegistry.h |
this replaces the existing set of child nodes with the new set.
Parameters
nodes | The list of nodes that will become children, bottom-up -- the first node, is the bottom-most node in the stack. |
Sets the state of the node to the value of collapsed
Parameters
collapsed | (no description provided) |
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.
Parameters
index | an integer corresponding to the set of available color labels. |
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.
Parameters
colorProfile | (no description provided) |
Return
if assigning the color profile worked |
convert the node to the given colorspace
Parameters
colorModel | A string describing the color model of the node:
|
colorDepth | A string describing the color depth of the image:
|
colorProfile | a valid color profile for this color model and color depth combination. |
Return
(no description provided) |
set the Inherit Alpha flag to the given value
Parameters
value | (no description provided) |
set a new layer style for this node.
Parameters
asl | (no description provided) |
Return
true if layer style was set, false if failed. |
set the Locked flag to the give value
Parameters
value | (no description provided) |
rename the Node to the given name
Parameters
name | (no description provided) |
set the opacity of the Node to the given value. The opacity is a value between 0 and 255.
Parameters
value | (no description provided) |
Sets whether or not node should be pinned to the Timeline Docker, regardless of selection activity.
Parameters
pinned | (no description provided) |
writes the given bytes, of which there must be enough, into the Node, if the Node has writable pixel data:
- paint layer: the layer's original pixels are overwritten
- filter layer, generator layer, any mask: the embedded selection's pixels are overwritten. Note: for these
File layers, Group layers, Clone layers cannot be written to. Calling setPixelData on those layer types will silently do nothing.
Parameters
value | the 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. |
x | the x position to start writing from |
y | the y position to start writing from |
w | the width of each row |
h | the number of rows to write |
Return
true if writing the pixeldata worked |
Should the node be visible in the timeline. It defaults to false with new layer
Parameters
showInTimeline | (no description provided) |
Set the visibility of the current node to visible
Parameters
visible | (no description provided) |
perform a shear operation on this node.
Parameters
angleX | the X-angle in degrees to shear by |
angleY | the Y-angle in degrees to shear by |
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.
Parameters
w | (no description provided) |
h | (no description provided) |
Return
a QImage representing the layer contents. |
Krita has several types of nodes, split in layers and masks. Group layers can contain other layers, any layer can contain masks.
Return
The type of the node. Valid types are:
If the Node object isn't wrapping a valid Krita layer or mask object, and empty string is returned. |
uniqueId of the node
Return
a QUuid representing a unique id to identify the node |
Check whether the current Node is visible in the layer stack
Return
(no description provided) |