-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathff_api_contrast_adjustment.lua
52 lines (45 loc) · 1.43 KB
/
ff_api_contrast_adjustment.lua
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
function prepare()
end;
function truncate(value)
if value <= 0 then value = 0 end
if value >= 1 then value = 1 end
return value
end;
function get_sample(x,y)
contrast = (get_sample_grayscale(x, y, CONTRAST) * 2) - 1
factor = (259 * (contrast + 1)) / (1 * (259 - contrast))
local r, g, b, a = get_sample_map(x, y, COLOR)
local nr = truncate(factor * (r - 0.5) + 0.5)
local ng = truncate(factor * (g - 0.5) + 0.5)
local nb = truncate(factor * (b - 0.5) + 0.5)
return nr, ng, nb, a
end;
-- function prepare()
-- slider contrast control
-- contrast = (get_slider_input(CONTRAST) * 2) - 1
-- factor = (259 * (contrast + 1)) / (1 * (259 - contrast))
-- end;
-- function truncate(value)
-- if value <= 0 then value = 0 end
-- if value >= 1 then value = 1 end
-- return value
-- end;
-- function get_sample(x,y)
-- local r, g, b, a = get_sample_map(x, y, COLOR)
-- local nr = truncate(factor * (r - 0.5) + 0.5)
-- local ng = truncate(factor * (g - 0.5) + 0.5)
-- local nb = truncate(factor * (b - 0.5) + 0.5)
-- return nr, ng, nb, a
-- end;
-- function prepare()
-- no truncate
-- end;
-- function get_sample(x,y)
-- contrast = (get_sample_grayscale(x, y, CONTRAST) * 2) - 1
-- factor = (259 * (contrast + 1)) / (1 * (259 - contrast))
-- local r, g, b, a = get_sample_map(x, y, COLOR)
-- local nr = factor * (r - 0.5) + 0.5
-- local ng = factor * (g - 0.5) + 0.5
-- local nb = factor * (b - 0.5) + 0.5
-- return nr, ng, nb, a
-- end;