Class Shape
Build from Shape.h
+Krita 4.0.0↻Krita 5.2.0

The Shape class The shape class is a wrapper around Krita's vector objects.

Some example code to parse through interesting information in a given vector layer with shapes.

import sysfrom krita import *doc = Application.activeDocument()root = doc.rootNode()for layer in root.childNodes(): print (str(layer.type())+" "+str(layer.name())) if (str(layer.type())=="vectorlayer"): for shape in layer.shapes(): print(shape.name()) print(shape.toSvg())

Methods

absoluteTransformation() ➞ QTransform boundingBox() ➞ QRectF deselect() geometryProtected() ➞ bool isSelected() ➞ bool name() ➞ str parentShape() position() ➞ QPointF remove() ➞ bool select() selectable() ➞ bool setGeometryProtected(protect: bool) setName(name: str) setPosition(point: QPointF) setSelectable(selectable: bool) setTransformation(matrix: QTransform) setVisible(visible: bool) setZIndex(zindex: int) toSvg(prependStyles: bool = False, stripTextMode: bool = True) ➞ str transformation() ➞ QTransform update() updateAbsolute(box: QRectF) visible() ➞ bool zIndex() ➞ int

Re-implemented methods

type() ➞ str

Member documentation

absoluteTransformation() ➞ QTransform
+Krita 5.2.0

transformation the 2D transformation matrix of the shape including all grandparent transforms.

Return

the 2D transformation matrix.

boundingBox() ➞ QRectF
+Krita 4.0.0

the bounding box of the shape in points

Return

RectF containing the bounding box.

+Krita 5.0.0

deselects the shape.

geometryProtected() ➞ bool
+Krita 5.0.0

Return

whether the shape is protected from user changing the shape geometry.

isSelected() ➞ bool
+Krita 5.0.0

Return

whether the shape is selected.

name() ➞ str
+Krita 4.0.0

Return

the name of the shape

+Krita 5.2.0

Return

the parent GroupShape of the current shape.

position() ➞ QPointF
+Krita 4.0.0

the position of the shape in points.

Return

the position of the shape in points.

remove() ➞ bool
+Krita 5.0.0

delete the shape.

Return

(no description provided)

select()
+Krita 5.0.0

selects the shape.

selectable() ➞ bool
+Krita 5.0.0

Return

whether the shape is user selectable.

setGeometryProtected(protect: bool)
+Krita 5.0.0

Parameters

protect

whether the shape should be geometry protected from the user.

setName(name: str)
+Krita 4.0.0

Parameters

name

which name the shape should have.

setPosition(point: QPointF)
+Krita 4.0.0

set the position of the shape.

Parameters

point

the new position in points

setSelectable(selectable: bool)
+Krita 5.0.0

Parameters

selectable

whether the shape should be user selectable.

setTransformation(matrix: QTransform)
+Krita 5.0.0

set the 2D transformation matrix of the shape.

Parameters

matrix

the new 2D transformation matrix.

setVisible(visible: bool)
+Krita 4.0.0

Parameters

visible

whether the shape should be visible.

setZIndex(zindex: int)
+Krita 5.0.0

Parameters

zindex

set the shape zindex value.

toSvg(prependStyles: bool = False, stripTextMode: bool = True) ➞ str
+Krita 4.0.0↻Krita 5.0.0

convert the shape to svg, will not include style definitions.

Parameters

prependStyles

prepend the style data. Default: false

stripTextMode

enable strip text mode. Default: true

Return

the svg in a string.

transformation() ➞ QTransform
+Krita 5.0.0

the 2D transformation matrix of the shape.

Return

the 2D transformation matrix.

type() ➞ str
+Krita 4.0.0

Return

the type of shape.

update()
+Krita 5.0.0

queue the shape update.

updateAbsolute(box: QRectF)
+Krita 5.0.0

queue the shape update in the specified rectangle.

Parameters

box

the RectF rectangle to update.

visible() ➞ bool
+Krita 4.0.0

Return

whether the shape is visible.

zIndex() ➞ int
+Krita 5.0.0

Return

the zindex of the shape.