Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
IntColor.cs
Go to the documentation of this file.
1using UnityEngine;
2
3public static class IntColor
4{
5 public static Color32 FromLong(long i)
6 {
7 return new Color32((byte)(i / 16777216), (byte)(i % 16777216 / 65536), (byte)(i % 65536 / 256), (byte)(i % 256));
8 }
9
10 public static long ToLong(ref Color c)
11 {
12 return (int)c.r * 255 * 16777216 + (int)c.g * 255 * 65536 + (int)c.b * 255 * 256 + (int)(c.a * 255f);
13 }
14
15 public static Color32 FromInt(int i)
16 {
17 byte b = (byte)(i / 4194304 * 2);
18 byte b2 = (byte)(i % 4194304 / 32768 * 2);
19 byte b3 = (byte)(i % 32768 / 256 * 2);
20 byte a = (byte)(i % 256);
21 return new Color32((byte)Mathf.Min(b + ((b % 2 != 0) ? 1 : 2), 255), (byte)Mathf.Min(b2 + ((b2 % 2 != 0) ? 1 : 2), 255), (byte)Mathf.Min(b3 + ((b3 % 2 != 0) ? 1 : 2), 255), a);
22 }
23
24 public static int ToInt(ref Color c)
25 {
26 return (int)(c.r * 127f) * 4194304 + (int)(c.g * 127f) * 32768 + (int)(c.b * 127f) * 256 + (int)(c.a * 255f);
27 }
28
29 public static int ToInt(Color c)
30 {
31 return (int)(c.r * 127f) * 4194304 + (int)(c.g * 127f) * 32768 + (int)(c.b * 127f) * 256 + (int)(c.a * 255f);
32 }
33}
static Color32 FromLong(long i)
Definition: IntColor.cs:5
static long ToLong(ref Color c)
Definition: IntColor.cs:10
static int ToInt(ref Color c)
Definition: IntColor.cs:24
static Color32 FromInt(int i)
Definition: IntColor.cs:15
static int ToInt(Color c)
Definition: IntColor.cs:29