Skip to content

Turn a layer by turning its art, since the format has no angle - #33

Merged
freethinkel merged 1 commit into
mainfrom
issue-24-rotate
Aug 13, 2026
Merged

Turn a layer by turning its art, since the format has no angle#33
freethinkel merged 1 commit into
mainfrom
issue-24-rotate

Conversation

@freethinkel

Copy link
Copy Markdown
Owner

Closes #24.

A widget's meta is a size and nothing else (WidgetMeta: w, h, rgb, flags, reserved, source, sub, max), so there is nowhere in the .bin to store a rotation — only a hand turns, and that happens on the watch, around its pivot. So a rotation is a pixel edit: rotateAsset re-bakes the art the way invertAsset does, and the asset keeps the running total only so the inspector can show an absolute angle.

  • core/render/pixels.tsrotateAsset: canvas turn around the centre, canvas grown to the rotated bounding box. cf 4 becomes cf 5 for a turn that isn't a multiple of 90° (its corners need alpha); a JPEG resource keeps its codec and gets black corners.
  • assets.model.tsrotateImageRequested (a delta) + rotateImageFx: every frame of the layer turns by the same amount, the pinned original goes with the bake, and the layer moves back by half of the box's growth so the art stays put. A hand's pivot moves with it, keeping x + pivot — the point it rotates around at runtime — on the same pixel of the dial.
  • render.tsResizePreview.deg: the drag is previewed with a matrix, like a resize, and baked once on pointerup.
  • editor.svelte — a round handle above the selection box, ⇧ snaps to 15°.
  • props/geometry.svelte — an angle field under w/h.

Groups and bare rings are out: a group's children would each turn about their own centre, and a ring's angle is start/end.

npm test (193 tests), check, lint, format:check and build all pass; tests/doc-assets.browser.test.ts gains a rotate case (90° swaps w/h and moves the marker pixel into the right corner, 45° grows the box and lifts cf 4 to 5).

🤖 Generated with Claude Code

https://claude.ai/code/session_012GWjN3WkUvCAuuvuuZfH6j

Closes #24. A widget's meta is a size and nothing else, so there is nowhere
to store a rotation: rotateAsset re-bakes the pixels instead, like the invert
does, and the asset keeps the running total only so the inspector can show an
absolute angle.

The canvas gets a round handle above the selection box (shift snaps to 15°),
previewed with a matrix and baked once on pointerup, and the geometry section
an angle field under w/h. The bounding box grows around the centre, so the
layer moves back by half of the growth — a hand's pivot moves with it, keeping
the point it rotates around at runtime on the same pixel of the dial.
@freethinkel
freethinkel merged commit 12a3573 into main Aug 13, 2026
2 checks passed
@freethinkel
freethinkel deleted the issue-24-rotate branch August 13, 2026 20:26
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.

Ability to Rotate elements.

1 participant