Krita Source Code Documentation
Loading...
Searching...
No Matches
perchannel_crosschannel_filter_test Namespace Reference

Functions

 checkDocument (fileName, curves)
 
 checkResult (name, value, ref)
 
 createDocument (fileName, filterName, curves)
 
 modifyDocument (fileName, curves)
 

Variables

dict curvesCCC
 
dict curvesCCM
 
dict curvesPCC
 
dict curvesPCM
 
bool returned = True
 
 tmpFileNameCC = os.path.join(tmpDirname, 'testing_filter_cc.kra')
 
 tmpFileNamePC = os.path.join(tmpDirname, 'testing_filter_pc.kra')
 

Function Documentation

◆ checkDocument()

perchannel_crosschannel_filter_test.checkDocument ( fileName,
curves )

Definition at line 68 of file perchannel_crosschannel_filter_test.py.

68def checkDocument(fileName, curves):
69 # open testing document and check if filter properties are OK
70 returned = False
71
72 doc = Krita.instance().openDocument(fileName)
73 #Krita.instance().activeWindow().addView(doc)
74
75 nodes = doc.rootNode().childNodes()
76
77 if nodes[1].name() == "TestFilter":
78 returned = True
79
80 filter = nodes[1].filter()
81 # get filter configuration
82 cfg = filter.configuration()
83 for curveId, curveValue in curves.items():
84 if not checkResult(curveId, cfg.property(curveId), curveValue):
85 returned = False
86
87 doc.close()
88
89 return returned
90
91
static Krita * instance()
instance retrieve the singleton instance of the Application object.
Definition Krita.cpp:390

References checkResult(), and Krita.instance().

◆ checkResult()

perchannel_crosschannel_filter_test.checkResult ( name,
value,
ref )

Definition at line 17 of file perchannel_crosschannel_filter_test.py.

17def checkResult(name, value, ref):
18 if value == ref:
19 returned = True
20 isOk = "OK"
21 else:
22 returned = False
23 isOk = "INVALID"
24
25 print(f"Check {name}: '{value}' == '{ref}' --> {isOk}")
26 return returned
27
28

◆ createDocument()

perchannel_crosschannel_filter_test.createDocument ( fileName,
filterName,
curves )

Definition at line 29 of file perchannel_crosschannel_filter_test.py.

29def createDocument(fileName, filterName, curves):
30 doc = Krita.instance().createDocument(500, 500, "TestFilter", "RGBA", "U8", "", 72.0)
31 #Krita.instance().activeWindow().addView(doc)
32
33 filter = Krita.instance().filter(filterName)
34 selection = Selection()
35 selection.selectAll(doc.rootNode(), 255)
36 node = doc.createFilterLayer("TestFilter", filter, selection)
37 doc.rootNode().addChildNode(node, None)
38 # here need to retrieve filter from layer, using the one (filter 'filter' here) that has been created does nothing
39 filter2 = node.filter()
40 cfg = filter2.configuration()
41 for curveId, curveValue in curves.items():
42 cfg.setProperty(curveId, curveValue)
43 doc.refreshProjection()
44 doc.saveAs(fileName)
45 doc.close()
46
47
KisDocument * createDocument(QList< KisNodeSP > nodes, KisImageSP srcImage, const QRect &copiedBounds)

References createDocument(), and Krita.instance().

◆ modifyDocument()

perchannel_crosschannel_filter_test.modifyDocument ( fileName,
curves )

Definition at line 48 of file perchannel_crosschannel_filter_test.py.

48def modifyDocument(fileName, curves):
49 doc = Krita.instance().openDocument(fileName)
50 #Krita.instance().activeWindow().addView(doc)
51
52 nodes = doc.rootNode().childNodes()
53
54 if nodes[1].name() == "TestFilter":
55 returned = True
56
57 filter = nodes[1].filter()
58 # get filter configuration
59 cfg = filter.configuration()
60 for curveId, curveValue in curves.items():
61 cfg.setProperty(curveId, curveValue)
62
63 doc.refreshProjection()
64 doc.save()
65 doc.close()
66
67

References Krita.instance().

Variable Documentation

◆ curvesCCC

dict perchannel_crosschannel_filter_test.curvesCCC
Initial value:
1= {'nTransfers': 8,
2 'curve0': '0,0;0.5,1;1,0;',
3 'curve1': '0,0.01;1,0.91;',
4 'curve2': '0,0.02;1,0.92;',
5 'curve3': '0,0.03;1,0.93;',
6 'curve4': '0,0.04;1,0.94;',
7 'curve5': '0,0.05;1,0.95;',
8 'curve6': '0,0.06;1,0.96;',
9 'curve7': '0,0.07;1,0.97;',
10 'driver0': 0,
11 'driver1': 1,
12 'driver2': 2,
13 'driver3': 3,
14 'driver4': 4,
15 'driver5': 5,
16 'driver6': 6,
17 'driver7': 7
18 }

Definition at line 114 of file perchannel_crosschannel_filter_test.py.

◆ curvesCCM

dict perchannel_crosschannel_filter_test.curvesCCM
Initial value:
1= {'nTransfers': 8,
2 'curve0': '0,1;0.5,1;0,9;',
3 'curve1': '0,0.11;1,0.91;',
4 'curve2': '0,0.22;1,0.92;',
5 'curve3': '0,0.33;1,0.93;',
6 'curve4': '0,0.44;1,0.94;',
7 'curve5': '0,0.55;1,0.95;',
8 'curve6': '0,0.66;1,0.96;',
9 'curve7': '0,0.77;1,0.97;',
10 'driver0': 7,
11 'driver1': 6,
12 'driver2': 5,
13 'driver3': 4,
14 'driver4': 3,
15 'driver5': 2,
16 'driver6': 1,
17 'driver7': 0
18 }

Definition at line 132 of file perchannel_crosschannel_filter_test.py.

◆ curvesPCC

dict perchannel_crosschannel_filter_test.curvesPCC
Initial value:
1= {'nTransfers': 8,
2 'curve0': '0,0;0.5,1;1,0;',
3 'curve1': '0,0.01;1,0.91;',
4 'curve2': '0,0.02;1,0.92;',
5 'curve3': '0,0.03;1,0.93;',
6 'curve4': '0,0.04;1,0.94;',
7 'curve5': '0,0.05;1,0.95;',
8 'curve6': '0,0.06;1,0.96;',
9 'curve7': '0,0.07;1,0.97;'
10 }

Definition at line 93 of file perchannel_crosschannel_filter_test.py.

◆ curvesPCM

dict perchannel_crosschannel_filter_test.curvesPCM
Initial value:
1= {'nTransfers': 8,
2 'curve0': '0,1;0.5,1;0,9;',
3 'curve1': '0,0.11;1,0.91;',
4 'curve2': '0,0.22;1,0.92;',
5 'curve3': '0,0.33;1,0.93;',
6 'curve4': '0,0.44;1,0.94;',
7 'curve5': '0,0.55;1,0.95;',
8 'curve6': '0,0.66;1,0.96;',
9 'curve7': '0,0.77;1,0.97;'
10 }

Definition at line 103 of file perchannel_crosschannel_filter_test.py.

◆ returned

bool perchannel_crosschannel_filter_test.returned = True

Definition at line 153 of file perchannel_crosschannel_filter_test.py.

◆ tmpFileNameCC

perchannel_crosschannel_filter_test.tmpFileNameCC = os.path.join(tmpDirname, 'testing_filter_cc.kra')

Definition at line 163 of file perchannel_crosschannel_filter_test.py.

◆ tmpFileNamePC

perchannel_crosschannel_filter_test.tmpFileNamePC = os.path.join(tmpDirname, 'testing_filter_pc.kra')

Definition at line 156 of file perchannel_crosschannel_filter_test.py.