Skip to content

showcase: a preview of the drawing with a frame for the view (#150) - #205

Merged
tbolis merged 1 commit into
release/1.1.0from
feat/showcase-preview
Nov 2, 2026
Merged

tbolis merged 1 commit into
release/1.1.0from
feat/showcase-preview

Conversation

@tbolis

@tbolis tbolis commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Summary

Answers #150, a preview or minimap of the canvas, with a recipe and a live example. The library is not changed: toDataURL() already draws the whole drawing, whatever the zoom and pan of the view.

  • Showcase: a Preview section with a small copy of the whole drawing (a quarter of its size), drawn again with toDataURL({ multiplier }) after each change, undo, redo, zoom and clear. When the view is zoomed or panned, a frame on it shows the part which the canvas shows, from onViewChange.
  • The preview is drawn again from onChange, onObjectAdded and onObjectRemoved (the last two tell of the objects which code adds or removes), and after the zoom, reset and clear buttons, which tell nothing. A canvas which cannot be exported (an image of another site without CORS) has no preview.
  • README: a section "A preview of the drawing" with the recipe and what to draw it again after, and how to place the frame. CHANGELOG: a line under Added in 1.1.0.

Checks

yarn format:check, yarn lint, yarn typecheck and yarn build pass. yarn test: 423 passing and 1 todo (the library is not changed).

The showcase, built and served, in headless Chrome with a real mouse and a real two-finger gesture through the DevTools protocol, at a device pixel ratio of 1 and of 2: the preview is empty until the first change; each stroke changes it (the image is the size of the canvas times 0.25); undo goes back to the earlier image; the zoom button changes it and reset brings back the earlier image; clear blanks it. After a pinch to 4.00, the frame is at the position and the size which the view gives (left and top 0.375, width and height 0.25 of the preview), and it is gone after the reset.

Not checked: a physical touch device.

Notes for review

  • How to create a preview for a canvas object? #150 needs to be in the Fixes line of the release PR (Release v1.1.0 #196), as closing keywords do not act on a merge into release/1.1.0. It is an answer and an example, not a change of the library, so the issue could also be closed with a pointer to the README section.
  • The showcase has no automated tests, so the check above is manual.

@tbolis
tbolis force-pushed the feat/showcase-preview branch from 831811d to 156a339 Compare November 2, 2026 07:45
The Preview section has a small copy of the whole drawing, drawn again after
each change, undo, redo, zoom and clear with toDataURL({ multiplier }). When
the view is zoomed or panned, a frame shows the part which the canvas shows,
from onViewChange. The README has the recipe in "A preview of the drawing".
@tbolis
tbolis force-pushed the feat/showcase-preview branch from 156a339 to fc2459f Compare November 2, 2026 10:20
@tbolis
tbolis merged commit 857b5e5 into release/1.1.0 Nov 2, 2026
3 checks passed
@tbolis
tbolis deleted the feat/showcase-preview branch November 2, 2026 11:01
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.

1 participant