blob: 70673db58a678e8ba08c49a804a603bf39bdec1d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
//! The example from README.md, compiled by `zig build test`.
const sk = @import("sketch");
pub const State = struct { x: f32 = 480, y: f32 = 300, hue: f32 = 0 };
pub fn update(s: *State, in: *const sk.Input) void {
if (in.pressed(sk.Key.space)) s.hue += 30;
s.x += (in.mouse_x - s.x) * 0.1;
s.y += (in.mouse_y - s.y) * 0.1;
}
pub fn draw(s: *const State, f: *sk.Frame) void {
f.clear(0x202020);
f.fill(.{ .x = s.x - 10, .y = s.y - 10, .w = 20, .h = 20 }, 0xff8040);
f.print(8, 8, 2, 0xffffff, "hue {d}", .{s.hue});
}
|