Skip to content

Build your personal knowledge base with Trilium Notes

8.9 KB
Raw Blame
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Trilium DMG volume icon</title>
<style>
    html, body { margin: 0; padding: 0; background: transparent; }

    /* The design is authored once in a 1024 x 1024 box and scaled to the target slot size by
       generate.mts (--scale), so every slot is rendered from vectors instead of downsampled from
       one bitmap. Chromium rasterises the SVG at the scaled device resolution, which keeps the
       16pt sidebar slot as crisp as the 1024 one. */
    .stage {
        width: 1024px;
        height: 1024px;
        transform: scale(var(--scale, 1));
        transform-origin: 0 0;
    }
    svg { display: block; }
</style>
</head>
<body>
<div class="stage" id="stage">
    <!-- Geometry measured off the icon macOS itself shows for a DMG with no custom volume icon
         (NSWorkspace icon for a mounted, unbranded image), so this reads as a disk image in the
         system's own form language rather than as a bespoke box. On a 1024 canvas that reference
         is: body 719 x 877 at (152, 74) — portrait, aspect 0.82 — corner radius ~60, and a silver
         base plinth occupying the bottom ~12%, with the glyph centred in the area above it. The
         only deliberate departure is the glyph: Apple's grey download arrow becomes the brand
         mark, in full colour, which is the entire point of shipping our own. -->
    <svg viewBox="0 0 1024 1024" width="1024" height="1024" xmlns="http://www.w3.org/2000/svg">
        <defs>
            <!-- Body: near-white with a faint vertical fall-off, matching the reference's
                 243-at-top / 235-near-the-base readings. -->
            <linearGradient id="body" x1="0" y1="0" x2="0" y2="1">
                <stop offset="0" stop-color="#fafafc"/>
                <stop offset="0.45" stop-color="#eeeff2"/>
                <stop offset="1" stop-color="#dcdee3"/>
            </linearGradient>
            <!-- Lateral bevel — the single biggest thing separating a native-looking drive from a
                 flat rectangle. The reference has NO outline stroke anywhere: the silhouette is
                 defined purely by shading, the shell darkening at each extreme edge with a bright
                 band just inside it, so it reads as a curved moulding catching light. -->
            <linearGradient id="bevel" x1="0" y1="0" x2="1" y2="0">
                <stop offset="0" stop-color="#7d828d" stop-opacity="0.34"/>
                <stop offset="0.012" stop-color="#8d919b" stop-opacity="0.20"/>
                <stop offset="0.035" stop-color="#ffffff" stop-opacity="0.55"/>
                <stop offset="0.10" stop-color="#ffffff" stop-opacity="0.16"/>
                <stop offset="0.22" stop-color="#ffffff" stop-opacity="0"/>
                <stop offset="0.78" stop-color="#ffffff" stop-opacity="0"/>
                <stop offset="0.90" stop-color="#ffffff" stop-opacity="0.24"/>
                <stop offset="0.962" stop-color="#ffffff" stop-opacity="0.62"/>
                <stop offset="0.986" stop-color="#8d919b" stop-opacity="0.22"/>
                <stop offset="1" stop-color="#7d828d" stop-opacity="0.36"/>
            </linearGradient>
            <!-- Light catching the drive's top face. -->
            <linearGradient id="topFace" x1="0" y1="0" x2="0" y2="1">
                <stop offset="0" stop-color="#ffffff" stop-opacity="0.95"/>
                <stop offset="1" stop-color="#ffffff" stop-opacity="0"/>
            </linearGradient>
            <!-- Base plinth: brushed metal, darker than the body so the silhouette has a foot. -->
            <!-- Keep the lit top edge NARROW. Spread over even a tenth of the plinth it stops
                 reading as a machined edge and washes the whole foot out to body tone, losing the
                 contrast that gives the silhouette its base. The reference drops from its highlight
                 to ~207 within a few units and bottoms out around 188, against a 235-243 body. -->
            <linearGradient id="plinth" x1="0" y1="0" x2="0" y2="1">
                <stop offset="0" stop-color="#fdfdfe"/>
                <stop offset="0.04" stop-color="#cdd0d6"/>
                <stop offset="0.45" stop-color="#b6b9c1"/>
                <stop offset="0.88" stop-color="#a1a4ad"/>
                <stop offset="1" stop-color="#b4b7bf"/>
            </linearGradient>
            <!-- NO soft contact shadow above the plinth. It is the obvious way to sell "this part
                 stands in front", and it is wrong here: measured down the centre column, the
                 reference holds the body at 235 right up to the join and then steps to 210, while
                 a gradient haze sags the body to ~205 first and destroys exactly the crisp step
                 that reads as an edge. A thin dark seam line does the job instead. -->
            <!-- Rounded bottom corners are the body's, so the plinth is drawn clipped to it. -->
            <clipPath id="bodyClip">
                <rect x="152" y="74" width="719" height="877" rx="60"/>
            </clipPath>
            <filter id="shade" x="-25%" y="-25%" width="150%" height="150%">
                <feDropShadow dx="0" dy="14" stdDeviation="20" flood-color="#4c5261" flood-opacity="0.26"/>
            </filter>
        </defs>

        <g filter="url(#shade)">
            <rect x="152" y="74" width="719" height="877" rx="60" fill="url(#body)"/>

            <g clip-path="url(#bodyClip)">
                <rect x="152" y="74" width="719" height="70" fill="url(#topFace)"/>

                <!-- Bevel goes on the SHELL, before the plinth — drawn over it instead, its bright
                     lateral bands wash the foot back to body tone and the base stops reading. -->
                <rect x="152" y="74" width="719" height="877" rx="60" fill="url(#bevel)"/>

                <!-- The plinth is a CAPSULE (radius = half its height), not a band spanning the
                     full width. Its rounded top corners let the body show behind them, which is
                     what makes it read as a metal foot standing in front of the shell rather than
                     a stripe printed on it. Only its bottom corners are the body's, via the clip.
                     The dark capsule behind it, offset a few units up, is the seam — it follows
                     the same curve, so the join stays crisp around the rounded ends too. -->
                <rect x="152" y="840" width="719" height="107" rx="53.5"
                      fill="#5f636e" fill-opacity="0.5"/>
                <rect x="152" y="844" width="719" height="107" rx="53.5" fill="url(#plinth)"/>
                <!-- Activity LED, right of centre on the plinth. -->
                <circle cx="790" cy="898" r="14" fill="#ffffff" fill-opacity="0.92"/>
            </g>
            <!-- Outline width AND opacity are set per slot by the script below, NOT fixed here.
                 See the note there: this exists only to rescue the small slots, and is faded out
                 entirely by the time the icon is big enough for the bevel to do the work. -->
            <rect id="outline" x="152" y="74" width="719" height="877" rx="60" fill="none"
                  stroke="#868c99"/>
        </g>

        <!-- Brand mark, single-sourced from the client's icon SVG (injected by generate.mts).
             Centred in the area above the plinth, where the reference puts its arrow, and sized
             to ~58% of the body width so it still reads as colour at the 16pt slot. -->
        <image id="mark" x="302" y="238" width="420" height="420" preserveAspectRatio="xMidYMid meet"/>
    </svg>
</div>
<script>
    const params = new URLSearchParams(location.search);
    const scale = parseFloat(params.get("scale") ?? "1");
    document.getElementById("stage").style.setProperty("--scale", scale);
    document.getElementById("mark").setAttribute("href", params.get("mark") ?? "");

    // The body outline is the one part that cannot live in design space. Everything else is an
    // area, so it shrinks gracefully; a stroke is a *width*, and a fixed 5 design units is 0.08
    // device px at the 16pt slot — i.e. gone, taking the drive silhouette with it and leaving the
    // mark floating on a white blob. Apple avoids this by hand-tuning their small slots. Deriving
    // the width from the slot scale gets the same result from one artwork: ~1.1 device px wherever
    // the slot is small enough to need it.
    //
    // It is a RESCUE for those slots, not part of the design: the reference has no outline at all,
    // and carrying one into the large slots is exactly what makes an icon read as a picture frame
    // instead of a drive. So it fades out as the bevel takes over — full below 64px, gone by 128.
    const outline = document.getElementById("outline");
    const px = 1024 * scale;
    outline.setAttribute("stroke-width", Math.max(5, 1.1 / scale));
    outline.setAttribute("stroke-opacity", 0.8 * Math.min(1, Math.max(0, (128 - px) / 64)));
</script>
</body>
</html>