Skip to content

Build your personal knowledge base with Trilium Notes

feat(desktop): frame the splash as a card on a neutral tray

Elian Dorancf2aaf99c85f
diff --git a/apps/desktop/electron-forge/setup-icon/generate/README.md b/apps/desktop/electron-forge/setup-icon/generate/README.md
index 827f3cf545..9bddaac01b 100644
--- a/apps/desktop/electron-forge/setup-icon/generate/README.md
+++ b/apps/desktop/electron-forge/setup-icon/generate/README.md
@@ -36,18 +36,31 @@ Run it on **Windows** so the wordmark renders in Segoe UI (the font is rasterize
frame GIF would be ~1.2 GiB and risks an OutOfMemoryException. The low-fps steady tail exists to
hold the count down.
+## Framing
+
+- The window has no chrome and no drop shadow (Squirrel's `Update.exe` is `WindowStyle.None` +
+ transparent), and GIF's 1-bit transparency can't cast a soft shadow onto the desktop. So the splash
+ is a **card on a tray**: an opaque light-neutral tray with a hairline edge, holding a rounded white
+ card whose soft shadow falls on the tray. That gives a defined, elevated boundary against any
+ surface — notably a white Explorer pane, where a plain white splash would vanish.
+
## Encoding
- Frames are **delta-encoded**: one global palette, and pixels unchanged from the previous frame are
written as a transparent index over the kept canvas (`dispose: 1`). This shrinks the mostly-static
steady tail to almost nothing (~140 KiB total). It saves file size only — not `Update.exe` memory,
which re-expands every frame to full size regardless.
+- The large flat colors (card white, tray, hairline, wordmark) are **pinned** into the palette:
+ gifenc's `applyPalette` nearest-color search is approximate, so without pinning the big white card
+ drifts to a warm near-white. `deriveAnchorColors()` reads these colors from the first rendered
+ frame and forces any exact-match pixel to that palette index, so changing the tray/card tone in
+ `splash.html` needs no change in the generator.
## Output contract
-- 640 × 480, opaque white background (GIF transparency is used for delta frames, but frame 0 is a
- full opaque frame so the loop resets cleanly and there is no reliance on desktop show-through),
- 108 frames, ~20 s loop, infinite loop, 255-color global palette, ~140 KiB.
+- 640 × 480, opaque; light-neutral tray (`#eceef1`) + white card. Transparency is used only for delta
+ frames — frame 0 is a full opaque frame, so the loop resets cleanly with no reliance on desktop
+ show-through. 108 frames, ~20 s loop, infinite loop, 255-color global palette, ~140 KiB.
- The mark and wordmark are drawn larger than strictly needed: Squirrel's `Update.exe` is not
DPI-aware, so on a HiDPI display the window is bilinear-stretched by the display scale factor
(e.g. 1.5×) and there is no way to signal density through a GIF. Bolder artwork survives that
diff --git a/apps/desktop/electron-forge/setup-icon/generate/generate.mts b/apps/desktop/electron-forge/setup-icon/generate/generate.mts
index cafd7c9c05..151c3e58b4 100644
--- a/apps/desktop/electron-forge/setup-icon/generate/generate.mts
+++ b/apps/desktop/electron-forge/setup-icon/generate/generate.mts
@@ -49,20 +49,30 @@ async function renderVariant(page: Page, variant: string): Promise<Buffer> {
frames.push(new Uint8Array(png.data.buffer, png.data.byteOffset, png.data.length).slice());
}
- const palette = buildGlobalPalette(frames);
+ const anchors = deriveAnchorColors(frames[0]);
+ const palette = buildGlobalPalette(frames, anchors);
const transparentIndex = palette.length; // 255: unused by applyPalette (0..254)
+ // gifenc's applyPalette nearest-color search is approximate (rgb565 cache), so the
+ // large flat white card drifts to a warm near-white even though pure white is in the
+ // palette. Pin any pixel that exactly matches an anchor to that anchor's index. The
+ // anchors are prepended in buildGlobalPalette, so anchor n is at palette index n.
+ const anchorIndexByColor = new Map<number, number>();
+ anchors.forEach(([r, g, b], i) => anchorIndexByColor.set((r << 16) | (g << 8) | b, i));
+
const gif = GIFEncoder();
let previous: Uint8Array | null = null;
for (const [i, { delay }] of timeline.entries()) {
const rgba = frames[i];
const index = applyPalette(rgba, palette);
- if (previous) {
- for (let p = 0; p < index.length; p++) {
- const b = p * 4;
- if (rgba[b] === previous[b] && rgba[b + 1] === previous[b + 1] && rgba[b + 2] === previous[b + 2]) {
- index[p] = transparentIndex;
- }
+ for (let p = 0; p < index.length; p++) {
+ const b = p * 4;
+ const anchor = anchorIndexByColor.get((rgba[b] << 16) | (rgba[b + 1] << 8) | rgba[b + 2]);
+ if (anchor !== undefined) {
+ index[p] = anchor;
+ }
+ if (previous && rgba[b] === previous[b] && rgba[b + 1] === previous[b + 1] && rgba[b + 2] === previous[b + 2]) {
+ index[p] = transparentIndex; // unchanged: keep prior canvas
}
}
gif.writeFrame(index, WIDTH, HEIGHT, {
@@ -81,10 +91,28 @@ async function renderVariant(page: Page, variant: string): Promise<Buffer> {
return Buffer.from(gif.bytes());
}
+// Flat backdrop colors that cover large areas and must reproduce exactly (left to the
+// quantizer they drift — the big white card goes warm). They are read straight from the
+// first frame (t = 0: empty card on the tray), so changing the tray/card tone in
+// splash.html needs no change here. The wordmark near-black is a small area but pinned
+// for crisp text. Sample points must stay inside their flat region.
+function deriveAnchorColors(frame0: Uint8Array): number[][] {
+ const pixel = (x: number, y: number) => {
+ const i = (y * WIDTH + x) * 4;
+ return [frame0[i], frame0[i + 1], frame0[i + 2]];
+ };
+ return [
+ pixel(WIDTH / 2, 60), // card (white; empty at t = 0)
+ pixel(3, 3), // tray (corner, outside the card)
+ pixel(0, HEIGHT / 2), // tray hairline (1px window edge)
+ [35, 41, 32] // wordmark (#232920)
+ ];
+}
+
// Builds one palette shared by every frame (required for cross-frame transparency).
// Sampling a handful of frames across the timeline captures the reveal's partial
// leaves plus the steady tail's dot-pulse tints without quantizing all ~110 frames.
-function buildGlobalPalette(frames: Uint8Array[]): number[][] {
+function buildGlobalPalette(frames: Uint8Array[], anchors: number[][]): number[][] {
const count = Math.min(frames.length, 6);
const step = Math.max(1, Math.floor(frames.length / count));
const sampled: Uint8Array[] = [];
@@ -97,7 +125,8 @@ function buildGlobalPalette(frames: Uint8Array[]): number[][] {
merged.set(frame, offset);
offset += frame.length;
}
- return quantize(merged, PALETTE_COLORS);
+ const quantized = quantize(merged, PALETTE_COLORS - anchors.length);
+ return [...anchors, ...quantized];
}
const browser = await chromium.launch();
diff --git a/apps/desktop/electron-forge/setup-icon/generate/splash.html b/apps/desktop/electron-forge/setup-icon/generate/splash.html
index 3a97e3717b..c0590bba41 100644
--- a/apps/desktop/electron-forge/setup-icon/generate/splash.html
+++ b/apps/desktop/electron-forge/setup-icon/generate/splash.html
@@ -10,17 +10,34 @@
overflow: hidden;
background: #ffffff;
}
+ /* The window has no chrome or shadow (Squirrel's Update.exe is WindowStyle.None
+ + transparent), and GIF's 1-bit transparency can't cast a soft shadow onto the
+ desktop. So the stage is an opaque neutral "tray" with a hairline edge, holding
+ a rounded white card whose soft shadow falls on the tray — giving the splash a
+ defined, elevated boundary against any surface (e.g. a white Explorer pane). */
.stage {
width: 640px;
height: 480px;
- background: #ffffff;
+ box-sizing: border-box;
+ background: #eceef1;
+ border: 1px solid #d7dae0;
display: flex;
- flex-direction: column;
align-items: center;
justify-content: center;
font-family: "Segoe UI", "Segoe UI Variable Text", system-ui, sans-serif;
user-select: none;
}
+ .card {
+ width: 582px;
+ height: 430px;
+ background: #ffffff;
+ border-radius: 18px;
+ box-shadow: 0 5px 18px rgba(22, 24, 30, 0.16), 0 1px 3px rgba(22, 24, 30, 0.10);
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ }
svg.mark {
width: 236px;
height: 236px;
@@ -78,6 +95,7 @@
</head>
<body>
<div class="stage" id="stage">
+ <div class="card">
<svg class="mark" viewBox="0 0 256 256" aria-label="Trilium mark" role="img">
<g class="leaf leaf-green">
<path class="g1" d="m202.9 112.7c-22.5 16.1-54.5 12.8-74.9 6.3l14.8-11.8 14.1-11.3 49.1-39.3-51.2 35.9-14.3 10-14.9 10.5c0.7-21.2 7-49.9 28.6-65.4 1.8-1.3 3.9-2.6 6.1-3.8 2.7-1.5 5.7-2.9 8.8-4.1 27.1-11.1 68.5-15.3 85.2-9.5 0.1 16.2-15.9 45.4-33.9 65.9-2.4 2.8-4.9 5.4-7.4 7.8-3.4 3.5-6.8 6.4-10.1 8.8z"/>
@@ -99,6 +117,7 @@
<div class="status">
<span class="dots"><span class="dot d1"></span><span class="dot d2"></span><span class="dot d3"></span></span>
</div>
+ </div>
</div>
<script>
const stage = document.getElementById("stage");
diff --git a/apps/desktop/electron-forge/setup-icon/setup-banner-dev.gif b/apps/desktop/electron-forge/setup-icon/setup-banner-dev.gif
index 6d9d1246c2..3037bf780e 100644
Binary files a/apps/desktop/electron-forge/setup-icon/setup-banner-dev.gif and b/apps/desktop/electron-forge/setup-icon/setup-banner-dev.gif differ
diff --git a/apps/desktop/electron-forge/setup-icon/setup-banner.gif b/apps/desktop/electron-forge/setup-icon/setup-banner.gif
index bd8f331b82..a0d6119e5b 100644
Binary files a/apps/desktop/electron-forge/setup-icon/setup-banner.gif and b/apps/desktop/electron-forge/setup-icon/setup-banner.gif differ