Added background image, TTF loading, rgb color struct
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
const sdl = @import("../sdl.zig").c;
|
||||
|
||||
pub const RGBAColor = struct {
|
||||
r: u8,
|
||||
g: u8,
|
||||
b: u8,
|
||||
a: u8,
|
||||
|
||||
pub fn white() RGBAColor {
|
||||
return .{
|
||||
.r = 0xff,
|
||||
.g = 0xff,
|
||||
.b = 0xff,
|
||||
.a = 0xff,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn black() RGBAColor {
|
||||
return .{
|
||||
.r = 0x00,
|
||||
.g = 0x00,
|
||||
.b = 0x00,
|
||||
.a = 0xff,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn red() RGBAColor {
|
||||
return .{
|
||||
.r = 0xff,
|
||||
.g = 0x00,
|
||||
.b = 0x00,
|
||||
.a = 0xff,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn green() RGBAColor {
|
||||
return .{
|
||||
.r = 0x00,
|
||||
.g = 0xff,
|
||||
.b = 0x00,
|
||||
.a = 0xff,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn blue() RGBAColor {
|
||||
return .{
|
||||
.r = 0x00,
|
||||
.g = 0x00,
|
||||
.b = 0xff,
|
||||
.a = 0xff,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn yellow() RGBAColor {
|
||||
return .{
|
||||
.r = 0xff,
|
||||
.g = 0xff,
|
||||
.b = 0x00,
|
||||
.a = 0xff,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn cyan() RGBAColor {
|
||||
return .{
|
||||
.r = 0x00,
|
||||
.g = 0xff,
|
||||
.b = 0xff,
|
||||
.a = 0xff,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn magenta() RGBAColor {
|
||||
return .{
|
||||
.r = 0xff,
|
||||
.g = 0x00,
|
||||
.b = 0xff,
|
||||
.a = 0xff,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn whiteSmoke() RGBAColor {
|
||||
return .{
|
||||
.r = 0xf5,
|
||||
.g = 0xf5,
|
||||
.b = 0xf5,
|
||||
.a = 0xff,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn orange() RGBAColor {
|
||||
return .{
|
||||
.r = 0xff,
|
||||
.g = 0xa5,
|
||||
.b = 0x00,
|
||||
.a = 0xff,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn pink() RGBAColor {
|
||||
return .{
|
||||
.r = 0xff,
|
||||
.g = 0xc0,
|
||||
.b = 0xcb,
|
||||
.a = 0xff,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn tosdl(self: *const RGBAColor) sdl.SDL_Color {
|
||||
return .{
|
||||
.r = self.r,
|
||||
.g = self.g,
|
||||
.b = self.b,
|
||||
.a = self.a,
|
||||
};
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user