Krita Source Code Documentation
Loading...
Searching...
No Matches
mutator.mutator.Mutator Class Reference
+ Inheritance diagram for mutator.mutator.Mutator:

Public Member Functions

 __init__ (self, parent)
 
 createActions (self, window)
 
 mutate (self)
 
 setup (self)
 

Public Attributes

 mutate
 

Detailed Description

 Mutator Class - Krita Extension 
The Mutator Krita extension script randomly mutates some of the artist's 
key brush and color settings by some configurable amount.
(When the extension is active settings can be configured in Krita's GUI using sliders in the MutatorDocker.)

Definition at line 64 of file mutator.py.

Constructor & Destructor Documentation

◆ __init__()

mutator.mutator.Mutator.__init__ ( self,
parent )

Definition at line 70 of file mutator.py.

70 def __init__(self,parent):
71 super().__init__(parent)
72
73

References mutator.mutator.Mutator.__init__().

Member Function Documentation

◆ createActions()

mutator.mutator.Mutator.createActions ( self,
window )
Adds an "action" to the Krita menus, which connects to the mutate function.

Definition at line 78 of file mutator.py.

78 def createActions(self, window):
79 '''
80 Adds an "action" to the Krita menus, which connects to the mutate function.
81 '''
82 action = window.createAction("mutate", "Mutate", "tools/scripting")
83 action.triggered.connect(self.mutate)
84
85

◆ mutate()

mutator.mutator.Mutator.mutate ( self)
Mutates current brush/color/etc. settings by some user-configurable amount.
Configurable settings are some percentage of a hard maximum amount for usability tuning.
Mutation is triggered *manually* by the artist via action, hotkey, or button,
whenever some randomness or brush/color variation is desired.

Definition at line 86 of file mutator.py.

86 def mutate(self):
87 '''
88 Mutates current brush/color/etc. settings by some user-configurable amount.
89 Configurable settings are some percentage of a hard maximum amount for usability tuning.
90 Mutation is triggered *manually* by the artist via action, hotkey, or button,
91 whenever some randomness or brush/color variation is desired.
92 '''
93 window = Krita.instance().activeWindow()
94 if window == None:
95 return
96 view = window.activeView()
97 if view == None:
98 return
99 if view.document() == None:
100 return
101
102 #Brush mutations...
103 newSize = view.brushSize() + calculate_mutation(clamp(sizeMutMax()[0], sizeMutMax()[1], view.brushSize()) * sizeMutMax()[2], nSizeMut)
104 view.setBrushSize(clamp(1, 1000, newSize))
105
106 newRotation = view.brushRotation() + calculate_mutation(rotationMutMax, nRotationMut)
107 view.setBrushRotation(newRotation)
108
109 newOpacity = view.paintingOpacity() + calculate_mutation(opacityMutMax, nOpacityMut)
110 view.setPaintingOpacity(clamp(0.01, 1, newOpacity))
111
112 newFlow = view.paintingFlow() + calculate_mutation(flowMutMax, nFlowMut)
113 view.setPaintingFlow(clamp(0.01, 1, newFlow))
114
115 #Color mutations...
116 managedColorFG = view.foregroundColor()
117 canvasColorFG = managedColorFG.colorForCanvas(view.canvas())
118
119 mutatedNormalizedHue = canvasColorFG.hueF() + calculate_mutation(hueMutMax, nHueMut)
120 mutatedNormalizedSaturation = clamp(0.01, 1, canvasColorFG.saturationF() + calculate_mutation(saturationMutMax, nSaturationMut))
121 mutatedNormalizedValue = clamp(0, 1, canvasColorFG.valueF() + calculate_mutation(valueMutMax, nValueMut))
122
123 canvasColorFG.setHsvF(mutatedNormalizedHue, mutatedNormalizedSaturation, mutatedNormalizedValue)
124 view.setForeGroundColor(ManagedColor.fromQColor(canvasColorFG))
125
126 # Low-priority canvas-floating message...
127 view.showFloatingMessage(i18n("Settings mutated!"), QIcon(), 1000, 2)
128
129
static Krita * instance()
instance retrieve the singleton instance of the Application object.
Definition Krita.cpp:390
static ManagedColor * fromQColor(const QColor &qcolor, Canvas *canvas=0)
fromQColor is the (approximate) reverse of colorForCanvas()
void clamp(float *r, float *g, float *b)

References mutator.mutator.calculate_mutation(), mutator.mutator.clamp(), ManagedColor.fromQColor(), Krita.instance(), and mutator.mutator.sizeMutMax().

◆ setup()

mutator.mutator.Mutator.setup ( self)

Definition at line 74 of file mutator.py.

74 def setup(self):
75 pass
76
77

Member Data Documentation

◆ mutate

mutator.mutator.Mutator.mutate

Definition at line 83 of file mutator.py.


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