summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 12:10:40 -0300
committerGabriel Schneider <[email protected]>2026-11-12 13:22:02 -0300
commitf8d3a32f4f995eeb7e162b0702998b0565c11e4e (patch)
tree66ac9e007f9bedb3ce86a3f56a7bc9773c89b96e
parentc84019e2f561a128ecdb8d50b39d510cae65d6e7 (diff)
downloadsketchbook-f8d3a32f4f995eeb7e162b0702998b0565c11e4e.tar.gz
sketchbook-f8d3a32f4f995eeb7e162b0702998b0565c11e4e.zip
sketchbook: a scene file says its page colour (background)
-rw-r--r--README.md18
-rw-r--r--src/anim/player.zig4
2 files changed, 18 insertions, 4 deletions
diff --git a/README.md b/README.md
index ba6598a..6062e60 100644
--- a/README.md
+++ b/README.md
@@ -110,6 +110,14 @@ in; `SKETCHBOOK_FONT="JetBrains Mono"` in the environment puts an
installed family before it. On the web it is the page's `monospace`, 8 px a
character.
+`f.textIn(face, x, y, scale, bytes, color)` is the same line in another
+face of the Go family, all six bundled in the binary (`sk.Face`): `.mono`,
+`.mono_bold`, `.mono_italic` for data and code, `.sans`, `.sans_medium`,
+`.sans_bold` for what is said about it; `f.host.textSizeIn(face, scale,
+bytes)` measures it. The three mono faces advance alike (0.6 em: whole
+pixels at 25, 30, 35, 45 and 60 px and at their doubles), so columns of
+text need no measuring. The web host draws every face as its one.
+
`f.openFile("open", .{ .pattern = "wav;flac" })` shows the system's file
dialog; the answer comes back as the console line `open <path>`, so it
reaches the sketch's `command` like anything typed there. `f.run(line)`
@@ -170,8 +178,10 @@ A `Pen` is plain data (`fill: ?Color`, `stroke: ?Color`, `width`, `join`,
`cap`, `xf: Affine`), so it can be a `const`, a State field, or a copy
changed for one call. A null fill is `noFill()`, a null stroke
`noStroke()`. `circle`, `line`, `polyline` (Processing's `beginShape()` /
-`endShape()`, open), `polygon` (`endShape(CLOSE)`), `rect` and `point` (a
-dot `width` across, Processing's `point`) tessellate into `f.scratch` and
+`endShape()`, open), `polygon` (`endShape(CLOSE)`), `rect`, `point` (a
+dot `width` across, Processing's `point`) and `dashed` (a polyline in
+dashes, `.{ on, off }` along the path, each dash whole round a corner;
+`Tessellation.strokeDashes` underneath) tessellate into `f.scratch` and
emit a shape for the fill and one for the stroke; out of memory, they log
and drop it, as `emit` does. Joins are `.miter` (bevelled past 4
half-widths), `.round` or `.bevel`, caps `.butt`, `.round` or `.square`;
@@ -429,7 +439,9 @@ returns a handle. Animations are methods of the handle: `write`, `create`,
options are `.seconds`, `.ease` (any `fn (f32) f32`) and `.lag` (manim's
lag ratio). `wait` moves time on, `pause()` holds the player there until a
click, like a slide. Positions are scene units: 1280x720 of them show at
-camera zoom 1, the origin in the middle, y down.
+camera zoom 1, the origin in the middle, y down. The page behind them is
+the scene file's `pub const background = 0xRRGGBB` (manim's grey without
+one).
A scene is one of two kinds, which share every call:
diff --git a/src/anim/player.zig b/src/anim/player.zig
index bac5178..090b6cb 100644
--- a/src/anim/player.zig
+++ b/src/anim/player.zig
@@ -26,6 +26,8 @@ const typst = @import("typst");
const geom = vector.geom;
pub const name = if (@hasDecl(scene_file, "name")) scene_file.name else "anim";
+/// The page: the scene file's `background` (0xRRGGBB), or manim's.
+const background: u32 = if (@hasDecl(scene_file, "background")) scene_file.background else anim.background;
/// The scene's frame, in scene units: what shows at camera zoom 1.
pub const width = 1280;
pub const height = 720;
@@ -234,7 +236,7 @@ fn paint(s: *const State, ss: *Session, layers: anytype, f: *sk.Frame, shot: ani
const world = stage(s, shot.camera, canvas);
var used: usize = 0;
// The first layer is the background too.
- var open: ?*@TypeOf(layers.items[0]) = try begun(layers, &used, f, canvas, anim.color(anim.background));
+ var open: ?*@TypeOf(layers.items[0]) = try begun(layers, &used, f, canvas, anim.color(background));
var shapes: usize = 0;
for (shot.objects, shot.poses, 0..) |o, pose, i| {
if (!pose.visible or pose.opacity <= 0) continue;