-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBlend.java
50 lines (42 loc) · 1.08 KB
/
Blend.java
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
public class Blend
{
public static final int NORMAL = 0;
public static final int INVERT = 1;
public static final int LIGHTEN = 2;
public static final int DARKEN = 3;
public static final int COLORIZE = 4;
private static int current_mode = NORMAL;
public static void setMode(int mode)
{
current_mode = mode;
}
public static int normal(int c1, int c2, int t)
{
int r = ((Col.getr(c1) * t) + (Col.getr(c2) * (255 - t))) / 255;
int g = ((Col.getg(c1) * t) + (Col.getg(c2) * (255 - t))) / 255;
int b = ((Col.getb(c1) * t) + (Col.getb(c2) * (255 - t))) / 255;
return Col.makeRGB(r, g, b);
}
public static int invert(int c1, int c2, int t)
{
return Col.makeRGB(255 - Col.getr(c1),
255 - Col.getg(c1), 255 - Col.getb(c1));
}
public static int current(int c1, int c2, int t)
{
switch(current_mode)
{
case NORMAL:
return normal(c1, c2, t);
case INVERT:
return invert(c1, c2, t);
case LIGHTEN:
break;
case DARKEN:
break;
case COLORIZE:
break;
}
return 0;
}
}