summaryrefslogtreecommitdiff
path: root/src/abi.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 11:13:20 -0300
committerGabriel Schneider <[email protected]>2026-11-12 13:22:02 -0300
commit86ffca0024326110962f0880727f4eb84e6a48d1 (patch)
tree055f489341053c1db258606bb63b282bc7345a89 /src/abi.zig
parenta62a6aa896adda901d335ef38814a13b8839545c (diff)
downloadsketchbook-86ffca0024326110962f0880727f4eb84e6a48d1.tar.gz
sketchbook-86ffca0024326110962f0880727f4eb84e6a48d1.zip
sketchbook: frames for ffmpeg (--export, on a clock of its own), text sizes, a font from the environment
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Diffstat (limited to 'src/abi.zig')
-rw-r--r--src/abi.zig14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/abi.zig b/src/abi.zig
index 03e2978..b30b7ae 100644
--- a/src/abi.zig
+++ b/src/abi.zig
@@ -180,6 +180,9 @@ pub const Input = struct {
started: bool = false,
/// The console is open and owns the keyboard.
console: bool = false,
+ /// The host is exporting frames (`--export`): nobody watches or clicks,
+ /// so a player runs through once, without its controls, and quits.
+ exporting: bool = false,
/// The canvas.
width: f32 = 0,
height: f32 = 0,
@@ -578,6 +581,9 @@ pub const Host = struct {
freeBuffer: *const fn (*anyopaque, Buffer) void,
/// Zero while unknown.
imageSize: *const fn (*anyopaque, Image) [2]u32,
+ /// What `Command.text` gives the bytes at a scale: the width they
+ /// advance and the height of their line, in canvas units.
+ textSize: *const fn (*anyopaque, f32, []const u8) [2]f32,
/// `.none` if the file does not load.
loadSound: *const fn (*anyopaque, []const u8) Audio,
/// WAV, FLAC or Ogg Vorbis bytes in memory. Not cached. `.none` if
@@ -625,6 +631,14 @@ pub const Host = struct {
pub fn imageSize(h: Host, image: Image) [2]u32 {
return h.vtable.imageSize(h.ctx, image);
}
+ /// The size `f.text(x, y, scale, bytes, ...)` covers from `x, y`: width
+ /// and line height in canvas units, for laying text out (in `draw`:
+ /// `update` gets no host). Native text is shaped and hinted at the size
+ /// it is drawn, so a width is not a multiple of the scale: measure at
+ /// the scale drawn.
+ pub fn textSize(h: Host, scale: f32, bytes: []const u8) [2]f32 {
+ return h.vtable.textSize(h.ctx, scale, bytes);
+ }
pub fn loadSound(h: Host, path: []const u8) Audio {
return h.vtable.loadSound(h.ctx, path);
}