Skip to content

feat(kit): add kit/sketch.js, helpers for a film drawn on one canvas - #109

Merged
umiyosh merged 1 commit into
masterfrom
feat/issue-97-sketch-kit
Nov 18, 2026
Merged

umiyosh merged 1 commit into
masterfrom
feat/issue-97-sketch-kit

Conversation

@umiyosh

@umiyosh umiyosh commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Fixes #97. Part of #87.

Summary

New kit/sketch.js with the helpers the two canvas films of #87 each wrote by hand. All of them are pure functions of the time:

Helper What it does
sketch.camera A 2D camera of shots. It zooms by ratio, and a shot of no length cuts on its own frame.
sketch.view / sketch.onScreen Puts the camera on the canvas, and finds where a drawing point shows on screen
sketch.begin Resets the canvas state and paints the ground at the start of each frame
sketch.paper Grid paper over what the camera shows
sketch.label A label that lands at t0 and leaves at t1
sketch.line A hand-drawn polyline revealed by progress, with a seeded wobble
sketch.ellipse / sketch.box The points of a hand-drawn circle and box

Why

Writing the film is now the longest step of a rich run (6:07 in the #87 trial). About a quarter of that page was these helpers. The hand copies also caused rework:

  • canvas state left over between frames
  • labels landing on top of each other

sketch.begin and sketch.label remove the first.

The name is sketch to keep it apart from fx.canvas (which returns a 2D context) and fx.camera (which moves a DOM layer).

Change

File Change
kit/sketch.js The helpers
scripts/kit.ts Copies sketch.js into the kit
references/html-film.md A row in the tools table and a new section, "1 枚の canvas に描く", with each helper

Test

  • New tests/sketch.test.ts:
    • The camera cuts on a shot of no length and zooms by equal ratios (√4 at half time).
    • A film drawn only with sketch draws the same frame after seeking back, even with a globalAlpha left over on purpose. It changes on the cut and passes checkLayout with no page warnings.
  • make check passes.

Not done here: rewriting the #87 trial film with the helpers to measure how much smaller it gets. The next rich run will show that.

@umiyosh
umiyosh merged commit 59a7291 into master Nov 18, 2026
1 check passed
@umiyosh
umiyosh deleted the feat/issue-97-sketch-kit branch November 18, 2026 16:18
@umiyosh umiyosh mentioned this pull request Nov 18, 2026
1 of 2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kit: add canvas helpers for camera, landing labels, hand-drawn lines and paper

1 participant