2
* This file is part of the dis-Emi-A HaXe Library. Copyright (c) edA-qa mort-ora-y
3
* For full copyright and license information please refer to doc/license.txt.
8
import flash.filters.ColorMatrixFilter;
11
* A series of helpers to create Color filters
16
* This performs a pseudo-grayscale conversion, that is, based
17
* on the average intensity of the pixels -- since there is no filter
18
* to do true grayscale (based on max or min value of the pixels)
20
static public function grayscale( ) : ColorMatrixFilter
23
1.0/3, 1.0/3, 1.0/3, 0,0, // red
24
1.0/3, 1.0/3, 1.0/3, 0,0, // green
25
1.0/3, 1.0/3, 1.0/3, 0,0, // blue
26
0, 0, 0, 1.0,0 // alpha
28
return new ColorMatrixFilter( matrix );
31
static public function rgb( r : Float, g : Float, b : Float ) : ColorMatrixFilter
34
r*1.0/3, r*1.0/3, r*1.0/3, 0,0, // red
35
g*1.0/3, g*1.0/3, g*1.0/3, 0,0, // green
36
b*1.0/3, b*1.0/3, b*1.0/3, 0,0, // blue
37
0, 0, 0, 1.0,0 // alpha
39
return new ColorMatrixFilter( matrix );
43
* Like rgb but only applies at a certain level (That is, only partially colorizes)
45
* @param t [in] 0 <= t <= 1 for level of tinge
47
static public function rgbTinge( r : Float, g : Float, b : Float, t : Float ) : ColorMatrixFilter
53
tp + r*ts, r*ts, r*ts, 0,0, // red
54
g*ts, tp + g*ts, g*ts, 0,0, // green
55
b*ts, b*1.0/3, tp + b*ts, 0,0, // blue
56
0, 0, 0, 1.0,0 // alpha
58
return new ColorMatrixFilter( matrix );