Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6581 | leency | 1 | --BRUSH Remap: Grayscale (desaturate) |
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 | percent = 100 |
||
17 | |||
18 | -- |
||
19 | function desaturate(percent,r,g,b) -- V1.0 by Richard Fhager |
||
20 | p = percent / 100 |
||
21 | a = (math.min(math.max(r,g,b),255) + math.max(math.min(r,g,b),0)) * 0.5 * p |
||
22 | r = r + (a-r*p) |
||
23 | g = g + (a-g*p) |
||
24 | b = b + (a-b*p) |
||
25 | return r,g,b |
||
26 | end |
||
27 | -- |
||
28 | |||
29 | |||
30 | w, h = getbrushsize() |
||
31 | |||
32 | for x = 0, w - 1, 1 do |
||
33 | for y = 0, h - 1, 1 do |
||
34 | putbrushpixel(x, y, matchcolor(desaturate(percent,getcolor(getbrushpixel(x,y))))); |
||
35 | end |
||
36 | end |