Class Scratchpad
Build from Scratchpad.h
Krita 4.4.0Krita master

The Scratchpad class A scratchpad is a type of blank canvas area that can be painted on

with the normal painting devices

Methods

Scratchpad(view: View, defaultColor: QColor, parent: QWidget = None) canvasZoomLink()bool clear() contentBounds()QRect copyScratchpadImageData()QImage fillBackground() fillDefault() fillDocument(fullContent: bool = True) fillForeground() fillGradient(gradientVectorStart: QPoint = QPoint(), gradientVectorEnd: QPoint = QPoint(), gradientShape: str = "linear", gradientRepeat: str = "none", reverseGradient: bool = False, dither: bool = False) fillLayer(fullContent: bool = True) fillPattern(transform: QTransform = QTransform()) fillTransparent() linkCanvasZoom(value: bool) loadScratchpadImage(image: QImage) panCenter() panTo(x: qint32, y: qint32) scale()float scaleReset() scaleToFit() setCanvasZoomLink(value: bool) setFillColor(color: QColor) setMode(modeName: str) setModeManually(value: bool) setScale(scale: float)bool viewportBounds()QRect

Signals

contentChanged() scaleChanged(float) viewportChanged(QRect)

Member documentation

Scratchpad(view: View, defaultColor: QColor, parent: QWidget = None)
Krita 4.4.0

Parameters

view(no description provided)
defaultColor(no description provided)
parent(no description provided)

Return

(no description provided)

canvasZoomLink()bool
Krita master

return if scratchpad zoom level is linked with current view zoom level

Return

return True if connection between the zoom of the canvas and scratchpad (so they zoom in sync) is active

clear()
Krita 4.4.0Krita 5.2.0

Clears out scratchpad with color specified set during setup

contentBounds()QRect
Krita master

The content of scratchpad can be bigger or smaller than scratchpad dimension. The bounds return the area in which there's some content

Return

scratchpad content bounds as a QRect

Krita master

signal is emitted when scratchpad content is changed (stroke or fill)

Krita 4.4.0Krita 5.2.0

Take what is on the scratchpad area and grab image

Return

the image data from the scratchpad

Krita master

Fill the entire scratchpad with current background color

Krita master

Fill the entire scratchpad with default color

fillDocument(fullContent: bool = True)
Krita master

Fill the entire scratchpad with current document projection content

Parameters

fullContent

when True, full document projection is loaded in scratchpad, otherwise only content matching scratchpad viewport is loaded

Krita master

Fill the entire scratchpad with current foreground color

fillGradient(gradientVectorStart: QPoint = QPoint(), gradientVectorEnd: QPoint = QPoint(), gradientShape: str = "linear", gradientRepeat: str = "none", reverseGradient: bool = False, dither: bool = False)
Krita master

Fill the entire scratchpad with current gradient

Parameters

gradientVectorStart

is a QPoint to define origin of gradient Set an empty QPoint() to use default scratchpad top-left

gradientVectorEnd

is a QPoint to define end of gradient set an empty QPoint() to use default scratchpad bottom-right

gradientShape

define which gradient to apply, can be: - "linear" - "bilinear" - "radial" - "square" - "conical" - "conicalSymmetric" - "spiral" - "reverseSpiral" - "polygonal"

gradientRepeat

define how to repeat gradient, can be: - "none" - "alternate" - "forwards"

reverseGradient

a boolean to define if gradient is reversed or not

dither

a boolean to define if gradient is dithered or not

fillLayer(fullContent: bool = True)
Krita master

Fill the entire scratchpad with current layer content

Parameters

fullContent

when True, full layer content is loaded in scratchpad, otherwise only content matching scratchpad viewport is loaded

fillPattern(transform: QTransform = QTransform())
Krita master

Fill the entire scratchpad with current pattern

Parameters

transform

is QTransform that let define pattern scale/rotation property

Krita master

Fill the entire scratchpad with a transparent color

linkCanvasZoom(value: bool)
Krita 4.4.0Krita master

DEPRECATED -- USE setCanvasZoomLink() instead Makes a connection between the zoom of the canvas and scratchpad area so they zoom in sync

Parameters

value

If True (default) the scratchpad will share the current view zoom level. If False, then use scratchpad scale methods to define current zoom level

loadScratchpadImage(image: QImage)
Krita 4.4.0Krita master

Load image data to the scratchpad

Parameters

image

Image object to load

Krita master

pan scratchpad content to center content in viewport

panTo(x: qint32, y: qint32)
Krita master

pan scratchpad content to top-left position of scratchpad viewport Provided value are absolute

Parameters

x

abscissa position to pan to

y

ordinate position to pan to

scale()float
Krita master

return current zoom level applied on scratchpad (whatever the zoom source is: view zoom level or set manually)

Return

a float value (1.00 = 100%)

scaleChanged(float)
Krita master

signal is emitted when scratchpad scale is changed (from zoom canvas or manually)

Parameters

scale

updated scale value (1.00 = 100%)

Krita master

reset scale and pan to origin Note: call method is ignored if canvasZoomLink() is True

Krita master

calculate scale automatically to fit scratchpad content in scratchpad viewport Note: call method is ignored if canvasZoomLink() is True

setCanvasZoomLink(value: bool)
Krita master

Makes a connection between the zoom of the canvas and scratchpad area so they zoom in sync

Parameters

value

If True (default) the scratchpad will share the current view zoom level. If False, then use scratchpad scale methods to define current zoom level

setFillColor(color: QColor)
Krita 4.4.0Krita master

Define default fill color for scratchpad

Parameters

color(no description provided)
setMode(modeName: str)
Krita 4.4.0Krita master

Manually set what mode scratchpad is in. Ignored if "setModeManually is set to false

Parameters

modeName

Available options are: - "painting" - "panning" - "colorsampling"

setModeManually(value: bool)
Krita 4.4.0Krita master

Switches between a GUI controlling the current mode and when mouse clicks control mode

Parameters

value

Set to True allows GUI to control the mode with explicitly setting mode

setScale(scale: float)bool
Krita master

allow to manually set scratchpad zoom level Note: call method is ignored if canvasZoomLink() is True,

Parameters

scale

zoom level to apply (1.00 = 100%)

Return

if scale has been applied return True, otherwise return False

viewportBounds()QRect
Krita master

The viewport indicates which part of scratchpad content is visible. It takes in account the current translation & scale

Example 1: - Scratchpad size: 500x500 - Scratchpad content: 2000x2000 - Scratchpad scale: 1.0 - Scratchpad pan: 0, 0 Returned viewport is a QRect(0, 0, 500, 500) matching content really visible in scratchpad. If scale is 2.00, returned viewport will be QRect(0, 0, 250, 250) If scale is 0.50, returned viewport will be QRect(0, 0, 1000, 1000)

Example 2: - Scratchpad size: 500x500 - Scratchpad content: 2000x2000 - Scratchpad scale: 2.0 - Scratchpad pan: 500, 1500 Returned viewport is a QRect(500, 1500, 250, 250) matching content really visible in scratchpad.

Return

scratchpad viewport bounds as a QRect

Krita master

signal is emitted when scratchpad viewport has been modified (pan, zoom)

Parameters

rect

new viewport bounds