ona/demos/canvas.zig

45 lines
808 B
Zig
Raw Normal View History

2024-07-30 00:50:40 +02:00
const gfx = @import("gfx");
const gui = @import("gui");
const hid = @import("hid");
const ona = @import("ona");
pub const main = ona.App.game
.with_module(gfx)
.with_module(hid)
.with_module(gui)
.with_system(.load, ona.system_fn(load), .{ .label = "Hello Ona" }).build();
2024-08-15 00:52:27 +02:00
fn load(canvas: ona.Write(gui.Canvas)) !void {
2024-07-30 00:50:40 +02:00
const item = try canvas.state.append("", .{
2024-08-15 00:52:27 +02:00
.x = 0,
.y = 0,
2024-07-30 00:50:40 +02:00
.width = 256,
.height = 256,
});
2024-08-15 00:52:27 +02:00
try canvas.state.set_block(item, .{
2024-07-30 00:50:40 +02:00
.has_color = gfx.colors.purple,
});
try canvas.state.set_label(item, .{
.has_text = "Hello, world",
});
2024-08-15 00:52:27 +02:00
const item2 = try canvas.state.append("", .{
.x = 128,
.y = 128,
.width = 256,
.height = 256,
});
try canvas.state.set_block(item2, .{
.has_color = .{0, 1, 0, 1},
});
canvas.state.set_parent(item2, item);
2024-07-30 00:50:40 +02:00
}
2024-08-15 00:52:27 +02:00