Definition at line 3 of file ColorUtil.cs.
◆ HSVToRGB()
static Color ColorUtil.HSVToRGB |
( |
float |
H, |
|
|
float |
S, |
|
|
float |
V |
|
) |
| |
|
inlinestatic |
Definition at line 10 of file ColorUtil.cs.
11 {
13 if (S == 0f)
14 {
15 white.r = V;
16 white.g = V;
17 white.b = V;
18 }
19 else if (V == 0f)
20 {
21 white.r = 0f;
22 white.g = 0f;
23 white.b = 0f;
24 }
25 else
26 {
27 white.r = 0f;
28 white.g = 0f;
29 white.b = 0f;
30 float num = H * 6f;
31 int num2 = (int)Mathf.Floor(num);
32 float num3 = num - (float)num2;
33 float num4 = V * (1f - S);
34 float num5 = V * (1f - S * num3);
35 float num6 = V * (1f - S * (1f - num3));
36 switch (num2)
37 {
38 case -1:
39 white.r = V;
40 white.g = num4;
41 white.b = num5;
42 break;
43 case 0:
44 white.r = V;
45 white.g = num6;
46 white.b = num4;
47 break;
48 case 1:
49 white.r = num5;
50 white.g = V;
51 white.b = num4;
52 break;
53 case 2:
54 white.r = num4;
55 white.g = V;
56 white.b = num6;
57 break;
58 case 3:
59 white.r = num4;
60 white.g = num5;
61 white.b = V;
62 break;
63 case 4:
64 white.r = num6;
65 white.g = num4;
66 white.b = V;
67 break;
68 case 5:
69 white.r = V;
70 white.g = num4;
71 white.b = num5;
72 break;
73 case 6:
74 white.r = V;
75 white.g = num6;
76 white.b = num4;
77 break;
78 }
79 white.r = Mathf.Clamp(white.r, 0f, 1f);
80 white.g = Mathf.Clamp(white.g, 0f, 1f);
81 white.b = Mathf.Clamp(white.b, 0f, 1f);
82 }
83 return white;
84 }
References Color.
Referenced by RandomHSV().
◆ RandomHSV()
static Color ColorUtil.RandomHSV |
( |
float |
minS, |
|
|
float |
maxS, |
|
|
float |
minV, |
|
|
float |
maxV |
|
) |
| |
|
inlinestatic |
Definition at line 5 of file ColorUtil.cs.
6 {
8 }
static Color HSVToRGB(float H, float S, float V)
static int Range(int min, int max)
References HSVToRGB(), and Rand.Range().
The documentation for this class was generated from the following file: