-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFractControllerContrastDitherUnittest.j
60 lines (48 loc) · 2.34 KB
/
FractControllerContrastDitherUnittest.j
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
This file is part of FrACT10, a vision test battery.
Copyright © 2021 Michael Bach, bach@uni-freiburg.de, <https://michaelbach.de>
FractControllerContrastDitherUnittest.j
Created by Bach on 2020-08-17
*/
@import "FractControllerContrast.j"
@implementation FractControllerContrastDitherUnittest: FractControllerContrast {
}
- (void) drawStimulusInRect: (CGRect) dirtyRect forView: (FractView) fractView { //console.info("FractControllerContrastDitherUnittest>drawStimulusInRect", state);
stimStrengthInDeviceunits = 0.5; stimStrengthInDeviceunitsUnquantised = stimStrengthInDeviceunits;
[self calculateForeBackColors];
gColorBack = [Settings windowBackgroundColor];
[self prepareDrawing];
switch(state) {
case kStateDrawBack: break;
case kStateDrawFore:
[self drawFixMark]; break;
case kStateDrawFore2:
const xWidth = 3; let xPos = -400, xPos1 = -300;
CGContextSetFillColor(cgc, [CPColor whiteColor]);
//gColorFore = [CPColor colorWithPatternImage: [[CPImage alloc] initWithContentsOfFile: [[CPBundle mainBundle] pathForResource: "allRewards4800x200.png"]]];
// for some reason, the ditherimage is not a working pattern color when draw… is called for the first time…
for (let g1 = 127-10; g1 <= 127 + 10; g1++) {
for (let g2 = 0; g2 < 9; g2++) {
const g = (g1 + g2 / 9) / 255;//console.info("g * 255", g * 255)
gColorFore = [CPColor colorWithPatternImage: [Dithering image3x3withGray: g]];
CGContextSetFillColor(cgc, gColorFore);
CGContextFillRect(cgc, CGRectMake(xPos, 20, xWidth, 200));
CGContextFillRect(cgc, CGRectMake(xPos1, -220, xWidth, 200));
xPos += xWidth + 1; xPos1 +=xWidth;
}
xPos += xWidth
}
trialInfoString = "Dither Test";
break;
}
CGContextRestoreGState(cgc);
[super drawStimulusInRect: dirtyRect];
}
- (void) runStart { //console.info("FractControllerContrastLett>runStart");
nAlternatives = 2; nTrials = 9999;
[super runStart];
}
- (int) responseNumberFromChar: (CPString) keyChar { //console.info("FractControllerAcuityLetters>responseNumberFromChar: ", keyChar);
return -1;// -1: ignore; -2: invalid
}
@end