The card was always a receipt on a wide teal ground. A Background button
in the toolbar now opens a menu of 19 backdrops, all drawn on the canvas
the card is saved from:
- teal (as before), and 14 patterns: gingham, graph paper, kraft,
cyanotype, night dots, deckchair stripes, olive linen, seigaiha waves,
xuan paper, zigzag, terracotta, lilac lines, green velvet, apricot
polka;
- four landscape photos (alpine dawn, misty shore, dunes, forest lake),
1000x1500 JPEGs made for this plugin;
- a picture of the reader's own: pick it, drop it on the page or paste
it.
A slider sets the margin around the paper (24 to 160, 76 by default, in
place of the old fixed 207 a side and 4:3 height). A photo also has blur
and dim. The paper's shadow follows the ground.
The choice is kept in the plugin's options (magpie.options): saved a
moment after a slider settles, since magpie takes one write a second.
The reader's own picture is shrunk to a JPEG of at most ~44KB, within
the 64KB magpie keeps for a plugin's options.
The photos are JPEG data in page/bg/<id>.js, loaded when picked, not
image files: the frame's origin is opaque, so a picture loaded by URL
would taint the canvas, and Copy image and Save PNG would fail.
Thumbnails are in bg/thumbs.js, loaded when the menu first opens.
Run: bun test packages/day-card on the Linux test box (magpie-desktop,
via wsl-run; mote refused SSH at the time): 14 pass, 2 of them new
(names in every language and the photos' data; a saved choice made
sound). A Playwright harness served the page with magpie's plugin-page
CSP (sandbox allow-scripts, img-src own data:, connect-src 'none') and
a fake bridge, in Chromium and WebKit: each of the 19 backdrops drew
and saved a PNG through magpie.image (so the canvas was not tainted),
the menu picked dunes and saved {bg: dunes, pad: 120}, the blur and dim
sliders showed only for a photo, and a 2400px JPEG of one's own was
stored as 36-43KB data and drawn. No page errors in either engine. The
first run showed the menu's sliders over the card while closed
(display: flex beat [hidden]); fixed and run again.
Not tried: the real magpie app (WKWebView, WebKitGTK, WebView2), its
real options store, and the native file picker inside the frame.
44 lines
2.3 KiB
HTML
44 lines
2.3 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Day card</title>
|
|
<link rel="stylesheet" href="style.css">
|
|
<script src="_magpie/bridge.js"></script>
|
|
<script src="fonts.js"></script>
|
|
<script src="view.js"></script>
|
|
<script src="backgrounds.js"></script>
|
|
<script src="app.js" defer></script>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<div class="days">
|
|
<button type="button" class="step" id="prev" aria-label="Previous day" data-t-label="prev"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10 3.5 5.5 8l4.5 4.5"/></svg></button>
|
|
<div class="pick">
|
|
<button type="button" id="date" aria-haspopup="listbox" aria-expanded="false"><span id="date-text"></span><svg viewBox="0 0 16 16" aria-hidden="true"><path d="m4.5 6.5 3.5 3.5 3.5-3.5"/></svg></button>
|
|
<ul id="menu" role="listbox" hidden></ul>
|
|
</div>
|
|
<button type="button" class="step" id="next" aria-label="Next day" data-t-label="next"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M6 3.5 10.5 8 6 12.5"/></svg></button>
|
|
<button type="button" id="today" data-t="today">Today</button>
|
|
</div>
|
|
<div class="share">
|
|
<div class="bgpick">
|
|
<button type="button" id="bg" aria-haspopup="dialog" aria-expanded="false"><canvas id="bg-chip" aria-hidden="true"></canvas><span data-t="background">Background</span></button>
|
|
<div id="bg-pop" role="dialog" data-t-label="background" hidden>
|
|
<div id="bg-grid" role="radiogroup" data-t-label="background"></div>
|
|
<label class="slider"><span data-t="padding">Padding</span><input type="range" id="pad" min="24" max="160" step="4"></label>
|
|
<label class="slider photo-only"><span data-t="blur">Blur</span><input type="range" id="blur" min="0" max="20" step="1"></label>
|
|
<label class="slider photo-only"><span data-t="dim">Dim</span><input type="range" id="dim" min="0" max="60" step="1"></label>
|
|
<input type="file" id="file" accept="image/png,image/jpeg,image/webp" hidden>
|
|
</div>
|
|
</div>
|
|
<button type="button" id="copy" data-t="copy" disabled>Copy image</button>
|
|
<button type="button" id="save" data-t="save" disabled>Save PNG</button>
|
|
</div>
|
|
</header>
|
|
<p class="status" id="status" role="status"></p>
|
|
<main><canvas id="card"></canvas></main>
|
|
</body>
|
|
</html>
|