-
Notifications
You must be signed in to change notification settings - Fork 72
/
get_variance.ahk
55 lines (39 loc) · 868 Bytes
/
get_variance.ahk
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
;get_variance.ahk
get_variance(bcolor, fcolor)
{
StringLen, Length, bcolor
EnvDiv, Length, 2
StartChar=1
Loop
{
StringMid,Chunk,bcolor,%StartChar%,2
Chunk%A_Index%=%Chunk%
IfEqual, A_Index, %Length%, Break
EnvAdd, StartChar, 2
}
bcolorr := Chunk2
bcolorg := Chunk3
bcolorb := Chunk4
StringLen, Length, fcolor
EnvDiv, Length, 2
StartChar=1
Loop
{
StringMid,Chunk,fcolor,%StartChar%,2
Chunk%A_Index%=%Chunk%
IfEqual, A_Index, %Length%, Break
EnvAdd, StartChar, 2
}
fcolorr := Chunk2
fcolorg := Chunk3
fcolorb := Chunk4
hexpref = 0x
rdiff := (hexPref . bcolorr) - (hexPref . fcolorr)
gdiff := (hexPref . bcolorg) - (hexPref . fcolorg)
bdiff := (hexPref . bcolorb) - (hexPref . fcolorb)
Absrdiff := Abs(rdiff)
Absgdiff := ABS(gdiff)
Absbdiff := ABS(bdiff)
variance := ( Absrdiff + Absgdiff + Absbdiff )
return variance
}