Draw UV gradient
This commit is contained in:
@@ -6,8 +6,36 @@ const W = std.unicode.utf8ToUtf16LeStringLiteral;
|
|||||||
pub fn main() void {
|
pub fn main() void {
|
||||||
const con_out = uefi.system_table.con_out.?;
|
const con_out = uefi.system_table.con_out.?;
|
||||||
con_out.reset(false) catch unreachable;
|
con_out.reset(false) catch unreachable;
|
||||||
_ = con_out.outputString(W("Hi :D\r\n")) catch unreachable;
|
_ = con_out.outputString(W("UV gradient incoming...\r\n")) catch unreachable;
|
||||||
|
|
||||||
const boot_services = uefi.system_table.boot_services.?;
|
const boot_services = uefi.system_table.boot_services.?;
|
||||||
boot_services.stall(5 * 1000 * 1000) catch unreachable;
|
|
||||||
|
const graphics = boot_services.locateProtocol(
|
||||||
|
uefi.protocol.GraphicsOutput,
|
||||||
|
null,
|
||||||
|
) catch null;
|
||||||
|
|
||||||
|
const mode = graphics.?.*.mode;
|
||||||
|
const info = mode.*.info;
|
||||||
|
|
||||||
|
const width = info.horizontal_resolution;
|
||||||
|
const height = info.vertical_resolution;
|
||||||
|
|
||||||
|
var fb: [*]u8 = @ptrFromInt(mode.frame_buffer_base);
|
||||||
|
|
||||||
|
for (0..height) |y| {
|
||||||
|
for (0..width) |x| {
|
||||||
|
const idx = x + width * y;
|
||||||
|
const r: u8 = @truncate(@divTrunc(255 * x, width));
|
||||||
|
const g: u8 = @truncate(@divTrunc(255 * y, height));
|
||||||
|
const b: u8 = 127;
|
||||||
|
|
||||||
|
fb[4 * idx + 0] = b;
|
||||||
|
fb[4 * idx + 1] = g;
|
||||||
|
fb[4 * idx + 2] = r;
|
||||||
|
fb[4 * idx + 3] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (true) {}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user