ona/demos/canvas.zig

45 lines
808 B
Zig

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();
fn load(canvas: ona.Write(gui.Canvas)) !void {
const item = try canvas.state.append("", .{
.x = 0,
.y = 0,
.width = 256,
.height = 256,
});
try canvas.state.set_block(item, .{
.has_color = gfx.colors.purple,
});
try canvas.state.set_label(item, .{
.has_text = "Hello, world",
});
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);
}