summaryrefslogtreecommitdiff
path: root/test/export.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/export.zig')
-rw-r--r--test/export.zig23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/export.zig b/test/export.zig
new file mode 100644
index 0000000..d8b35ad
--- /dev/null
+++ b/test/export.zig
@@ -0,0 +1,23 @@
+//! Export's test: time comes from the ticks alone and moves a bar, the
+//! canvas is the room the host gives (`--size`), and it quits by itself.
+const sk = @import("sketch");
+
+pub const State = struct { t: f32 = 0, frames: u32 = 0 };
+
+pub fn update(s: *State, in: *const sk.Input) void {
+ for (in.events) |e| if (e.kind == .tick) {
+ s.t += e.x;
+ s.frames += 1;
+ };
+}
+
+pub fn draw(s: *const State, f: *sk.Frame) void {
+ const w = f.in.window_width;
+ const h = f.in.window_height;
+ f.canvas(@intFromFloat(w), @intFromFloat(h));
+ f.clear(0x202020);
+ // 300 px a second: 10 px a frame at 30 fps, whatever the wall clock did.
+ f.fill(sk.Rect{ .w = s.t * 300, .h = h / 2 }, 0xff8040);
+ f.print(8, h - 24, 1, 0xffffff, "frame {d} of {d:.0}x{d:.0}", .{ s.frames, w, h });
+ if (s.frames == 8) f.quit();
+}