-
Notifications
You must be signed in to change notification settings - Fork 0
/
Colorizer.cs
37 lines (30 loc) · 931 Bytes
/
Colorizer.cs
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
using System.Drawing;
namespace YellowSnow
{
class Colorizer
{
public static Color GetBGColor(int level)
{
Color from = Themes.Selected.bgOld;
Color to = Themes.Selected.bgNew;
return GetColor(level, from, to);
}
public static Color GetFGColor(int level)
{
Color from = Themes.Selected.fgOld;
Color to = Themes.Selected.fgNew;
return GetColor(level, from, to);
}
private static Color GetColor(int level, Color from, Color to)
{
float dR = to.R - from.R;
float dG = to.G - from.G;
float dB = to.B - from.B;
float l = level / 255.0f;
float r = dR * l + from.R;
float g = dG * l + from.G;
float b = dB * l + from.B;
return Color.FromArgb((byte)r, (byte)g, (byte)b);
}
}
}