summaryrefslogtreecommitdiff
path: root/src/sketch
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 12:53:22 -0300
committerGabriel Schneider <[email protected]>2026-11-12 13:22:02 -0300
commit45f705a5e590c3dfddc0a544e66beb9bf6205a4d (patch)
treec98d19a1b2dfc4808a46b41cf1b931703ff467b1 /src/sketch
parentf8d3a32f4f995eeb7e162b0702998b0565c11e4e (diff)
downloadsketchbook-45f705a5e590c3dfddc0a544e66beb9bf6205a4d.tar.gz
sketchbook-45f705a5e590c3dfddc0a544e66beb9bf6205a4d.zip
sketchbook: text rasterized at one scale and drawn at another (f.textScaled), steady under a moving camera
Diffstat (limited to 'src/sketch')
-rw-r--r--src/sketch/root.zig8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/sketch/root.zig b/src/sketch/root.zig
index 01aa977..81ebad5 100644
--- a/src/sketch/root.zig
+++ b/src/sketch/root.zig
@@ -152,6 +152,14 @@ pub const Frame = struct {
pub fn textIn(f: *Frame, face: Face, x: f32, y: f32, scale: f32, bytes: []const u8, color: anytype) void {
f.emit(.{ .text = .{ .x = x, .y = y, .scale = scale, .color = paint(color), .bytes = f.keep(u8, bytes), .face = face } });
}
+ /// `textIn` laid out and rasterized at `raster` and drawn at `scale`,
+ /// its position not snapped to a pixel: for text under a moving
+ /// camera. Rasterize at the scale the move ends on (or the larger of
+ /// its two ends): the letters keep their places against each other
+ /// all the way, and one texture serves every frame of the move.
+ pub fn textScaled(f: *Frame, face: Face, x: f32, y: f32, scale: f32, raster: f32, bytes: []const u8, color: anytype) void {
+ f.emit(.{ .text = .{ .x = x, .y = y, .scale = scale, .color = paint(color), .bytes = f.keep(u8, bytes), .face = face, .raster = raster } });
+ }
pub fn print(f: *Frame, x: f32, y: f32, scale: f32, color: anytype, comptime fmt: []const u8, args: anytype) void {
f.emit(.{ .text = .{ .x = x, .y = y, .scale = scale, .color = paint(color), .bytes = f.format(fmt, args) } });
}