Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6581 | leency | 1 | --PALETTE Adjust: Desaturate v1.1 |
2 | --by Richard Fhager |
||
3 | --http://hem.fyristorg.com/dawnbringer/ |
||
4 | |||
5 | -- Copyright 2010 Richard Fhager |
||
6 | -- |
||
7 | -- This program is free software; you can redistribute it and/or |
||
8 | -- modify it under the terms of the GNU General Public License |
||
9 | -- as published by the Free Software Foundation; version 2 |
||
10 | -- of the License. See |
||
11 | |||
12 | -- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project |
||
13 | -- http://goto.glocalnet.net/richard_fhager/evalion/evalion.html |
||
14 | |||
15 | |||
16 | -- Note: Negative values will work as INCREASED saturation, but I'm not sure if this function is 100% correct |
||
17 | |||
18 | |||
19 | --percent = 25 |
||
20 | |||
21 | OK,percent = inputbox("Desaturate Palette","Percent %", 25, 0,100,0); |
||
22 | |||
23 | -- |
||
24 | function desaturate(percent,r,g,b) -- V1.0 by Richard Fhager |
||
25 | p = percent / 100 |
||
26 | a = (math.min(math.max(r,g,b),255) + math.max(math.min(r,g,b),0)) * 0.5 * p |
||
27 | r = r + (a-r*p) |
||
28 | g = g + (a-g*p) |
||
29 | b = b + (a-b*p) |
||
30 | return r,g,b |
||
31 | end |
||
32 | -- |
||
33 | |||
34 | if OK == true then |
||
35 | |||
36 | for c = 0, 255, 1 do |
||
37 | setcolor(c, desaturate(percent,getcolor(c))) |
||
38 | end |
||
39 | |||
40 | end |