Turn a layer by turning its art, since the format has no angle - #33
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.binto store a rotation — only a hand turns, and that happens on the watch, around its pivot. So a rotation is a pixel edit:rotateAssetre-bakes the art the wayinvertAssetdoes, and the asset keeps the running total only so the inspector can show an absolute angle.core/render/pixels.ts—rotateAsset: 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.ts—rotateImageRequested(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, keepingx + pivot— the point it rotates around at runtime — on the same pixel of the dial.render.ts—ResizePreview.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— ananglefield 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:checkandbuildall pass;tests/doc-assets.browser.test.tsgains 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