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", i18n("Mutate"), "tools/scripts")
83 action.triggered.connect(self.mutate)
84

◆ 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 85 of file mutator.py.

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