From 45f705a5e590c3dfddc0a544e66beb9bf6205a4d Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 12:53:22 -0300 Subject: sketchbook: text rasterized at one scale and drawn at another (f.textScaled), steady under a moving camera --- src/sketch/root.zig | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/sketch/root.zig') 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) } }); } -- cgit v1.3