-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShader.cs
81 lines (74 loc) · 2.15 KB
/
Shader.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace Doob_eternal_2001
{
class Shader
{
Color color;
public int A, R, G, B;
public Shader(Color c)
{
A = c.A;
R = c.R;
G = c.G;
B = c.B;
color = c;
}
public Shader(int a,int r, int g, int b)
{
A = Clamp(a, 0, 255);
R = Clamp(r, 0, 255);
G = Clamp(g, 0, 255);
B = Clamp(b, 0, 255);
color = Color.FromArgb(A,R,G,B);
}
public static int Clamp(int value, int min, int max)
{
if (value < min)
{
value = min;
}
else if (value > max)
{
value = max;
}
return value;
}
public static implicit operator Color(Shader w)
{
return w.color;
}
public static implicit operator Shader(Color w)
{
return new Shader(w);
}
public static Shader operator +(Shader a, Shader b)
{
return new Shader(a.A + b.A, a.R + b.R, a.G + b.G, a.B+ b.B);
}
public static Shader operator -(Shader a, Shader b)
{
return new Shader(a.A - b.A, a.R - b.R, a.G - b.G, a.B - b.B);
}
public static Shader operator *(Shader a, double b)
{
return new Shader(a.A, (int)(a.R * b), (int)(a.G * b), (int)(a.B * b));
}
public static Shader operator *(Shader a, Shader b)
{
return new Shader(a.A * b.A, a.R * b.R, a.G * b.G, a.B * b.B);
}
public static Shader operator /(Shader a, double b)
{
return new Shader(a.A, (int)(a.R / b), (int)(a.G / b), (int)(a.B / b));
}
public static Shader operator /(Shader a, Shader b)
{
return new Shader(a.A / b.A, a.R / b.R, a.G / b.G, a.B / b.B);
}
}
}