diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-10 12:10:40 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-12 13:22:02 -0300 |
| commit | faf40df6f31e98eb752fd5e96330221c8f7dbcc7 (patch) | |
| tree | ab9356732afbbbb18e85f973945249a738863ae7 /src/anim | |
| parent | 71e534631bf68f33f802d64794340870374b9f69 (diff) | |
| download | sketchbook-faf40df6f31e98eb752fd5e96330221c8f7dbcc7.tar.gz sketchbook-faf40df6f31e98eb752fd5e96330221c8f7dbcc7.zip | |
sketchbook: text in six faces of the Go family, all bundled (f.textIn, host.textSizeIn, sk.Face)
Diffstat (limited to 'src/anim')
| -rw-r--r-- | src/anim/root.zig | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/anim/root.zig b/src/anim/root.zig index 00e9362..a676f38 100644 --- a/src/anim/root.zig +++ b/src/anim/root.zig @@ -186,6 +186,18 @@ pub const Placed = struct { f.text(at[0], at[1], scale * p.scale, bytes, p.faded(ink)); } + /// `text` in another face (`sk.Face`: bold or italic mono, the sans). + pub fn textIn(p: Placed, f: *sk.Frame, face: sk.Face, x: f32, y: f32, scale: f32, bytes: []const u8, ink: sk.Color) void { + const at = p.xf.apply(.{ x, y }); + f.textIn(face, at[0], at[1], scale * p.scale, bytes, p.faded(ink)); + } + + /// The width and line height `textIn` covers, in the object's units. + pub fn textSizeIn(p: Placed, f: *sk.Frame, face: sk.Face, scale: f32, bytes: []const u8) [2]f32 { + const size = f.host.textSizeIn(face, scale * p.scale, bytes); + return .{ size[0] / p.scale, size[1] / p.scale }; + } + /// The width and line height `text` covers, in the object's units. pub fn textSize(p: Placed, f: *sk.Frame, scale: f32, bytes: []const u8) [2]f32 { const size = f.host.textSize(scale * p.scale, bytes); |
