35 lines
697 B
Zig
35 lines
697 B
Zig
|
pub const Color = struct {
|
||
|
type: enum { Default, RGB },
|
||
|
red: u8,
|
||
|
green: u8,
|
||
|
blue: u8,
|
||
|
|
||
|
pub fn equal(self: Color, other: Color) bool {
|
||
|
if (self.type != other.type) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if (self.type == .Default) {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
return self.red == other.red and self.green == other.green and self.blue == self.blue;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
pub const Default = Color{
|
||
|
.type = .Default,
|
||
|
.red = undefined,
|
||
|
.green = undefined,
|
||
|
.blue = undefined,
|
||
|
};
|
||
|
|
||
|
pub inline fn RGB(red: u8, green: u8, blue: u8) Color {
|
||
|
return .{
|
||
|
.type = .RGB,
|
||
|
.red = red,
|
||
|
.green = green,
|
||
|
.blue = blue,
|
||
|
};
|
||
|
}
|