-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColor.cs
54 lines (43 loc) · 1.23 KB
/
Color.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
namespace BBQLib
{
public sealed class Color
{
public float r = 1, g = 1, b = 1, a = 1;
public Color()
{
}
public Color(float r, float g, float b, float a = 1)
{
this.r = r;
this.g = g;
this.b = b;
this.a = a;
}
public static Color operator + (Color a, Color b)
{
return new Color(a.r + b.r, a.g + b.g, a.b + b.b);
}
public static Color operator - (Color a, Color b)
{
return new Color(a.r - b.r, a.g - b.g, a.b - b.b);
}
public static Color operator * (Color a, float b)
{
return new Color(a.r * b, a.g * b, a.b * b);
}
public static Color Mix(Color A, Color B, float amount)
{
return (B - A) * amount + A;
}
public static Color CreateColor(float r, float g, float b, float a = 1)
{
return new Color(r,g,b,a);
}
public static Color From255RGB(byte r, byte g, byte b, byte a = 255)
{
return new Color((1f/255) * r, (1f/255) * g, (1f/255) * b, (1f/255) * a);
}
public static readonly Color Red = new Color(1, 0, 0, .25f);
}
}