|
| 1 | +package dev.vexide.hydrozoa.display; |
| 2 | + |
| 3 | +import org.jetbrains.annotations.Contract; |
| 4 | + |
| 5 | +public record Color(int raw) { |
| 6 | + public static final Color TRANSPARENT = new Color(0, true); |
| 7 | + public static final Color BLACK = new Color(0x000000); |
| 8 | + public static final Color SILVER = new Color(0xC0C0C0); |
| 9 | + public static final Color GRAY = new Color(0x808080); |
| 10 | + public static final Color WHITE = new Color(0xFFFFFF); |
| 11 | + public static final Color MAROON = new Color(0x800000); |
| 12 | + public static final Color RED = new Color(0xFF0000); |
| 13 | + public static final Color PURPLE = new Color(0x800080); |
| 14 | + public static final Color FUCHSIA = new Color(0xFF00FF); |
| 15 | + public static final Color GREEN = new Color(0x008000); |
| 16 | + public static final Color LIME = new Color(0x00FF00); |
| 17 | + public static final Color OLIVE = new Color(0x808000); |
| 18 | + public static final Color YELLOW = new Color(0xFFFF00); |
| 19 | + public static final Color NAVY = new Color(0x000080); |
| 20 | + public static final Color BLUE = new Color(0x0000FF); |
| 21 | + public static final Color TEAL = new Color(0x008080); |
| 22 | + public static final Color AQUA = new Color(0x00FFFF); |
| 23 | + public Color(int red, int green, int blue) { |
| 24 | + this(red, green, blue, false); |
| 25 | + } |
| 26 | + public Color(int red, int green, int blue, boolean transparent) { |
| 27 | + this((red << 16) | (green << 8) | blue, transparent); |
| 28 | + } |
| 29 | + public Color(int raw, boolean transparent) { |
| 30 | + this(raw | (transparent ? 0x1000000 : 0)); |
| 31 | + } |
| 32 | + |
| 33 | + @Contract(pure = true) |
| 34 | + public boolean transparent() { |
| 35 | + return (raw & 0x1000000) != 0; |
| 36 | + } |
| 37 | + |
| 38 | + @Contract(pure = true) |
| 39 | + public int red() { |
| 40 | + return (raw >> 16) & 0xFF; |
| 41 | + } |
| 42 | + |
| 43 | + @Contract(pure = true) |
| 44 | + public int green() { |
| 45 | + return (raw >> 8) & 0xFF; |
| 46 | + } |
| 47 | + |
| 48 | + @Contract(pure = true) |
| 49 | + public int blue() { |
| 50 | + return raw & 0xFF; |
| 51 | + } |
| 52 | +} |
0 commit comments