diff --git a/apps/maple-agent/app/packaging/icon/dev/MapleAgent.icon/Assets/badge.svg b/apps/maple-agent/app/packaging/icon/dev/MapleAgent.icon/Assets/badge.svg new file mode 100644 index 000000000..0eb78dfc5 --- /dev/null +++ b/apps/maple-agent/app/packaging/icon/dev/MapleAgent.icon/Assets/badge.svg @@ -0,0 +1 @@ + diff --git a/apps/maple-agent/app/packaging/icon/dev/MapleAgent.icon/Assets/m.svg b/apps/maple-agent/app/packaging/icon/dev/MapleAgent.icon/Assets/m.svg new file mode 100644 index 000000000..7cdc4580a --- /dev/null +++ b/apps/maple-agent/app/packaging/icon/dev/MapleAgent.icon/Assets/m.svg @@ -0,0 +1 @@ + diff --git a/apps/maple-agent/app/packaging/icon/dev/MapleAgent.icon/Assets/sheet.svg b/apps/maple-agent/app/packaging/icon/dev/MapleAgent.icon/Assets/sheet.svg new file mode 100644 index 000000000..72a99a543 --- /dev/null +++ b/apps/maple-agent/app/packaging/icon/dev/MapleAgent.icon/Assets/sheet.svg @@ -0,0 +1 @@ + diff --git a/apps/maple-agent/app/packaging/icon/dev/MapleAgent.icon/icon.json b/apps/maple-agent/app/packaging/icon/dev/MapleAgent.icon/icon.json new file mode 100644 index 000000000..3e1dc617c --- /dev/null +++ b/apps/maple-agent/app/packaging/icon/dev/MapleAgent.icon/icon.json @@ -0,0 +1,139 @@ +{ + "groups": [ + { + "name": "Badge", + "layers": [ + { + "name": "Badge", + "image-name": "badge.svg", + "glass": false, + "fill-specializations": [ + { + "value": { + "solid": "srgb:0.83137,0.63922,0.35294,1.00000" + } + }, + { + "appearance": "tinted", + "value": { + "solid": "srgb:0.75000,0.75000,0.75000,1.00000" + } + } + ] + } + ], + "shadow": { + "kind": "none", + "opacity": 0.5 + }, + "translucency": { + "enabled": false, + "value": 0.5 + }, + "specular": false, + "position": { + "scale": 1, + "translation-in-points": [ + 0, + 42.0 + ] + } + }, + { + "name": "M", + "layers": [ + { + "name": "M", + "image-name": "m.svg", + "glass": false, + "fill-specializations": [ + { + "value": { + "solid": "srgb:0.96863,0.96863,0.97647,1.00000" + } + }, + { + "appearance": "tinted", + "value": { + "solid": "srgb:1.00000,1.00000,1.00000,1.00000" + } + } + ] + } + ], + "shadow": { + "kind": "none", + "opacity": 0.5 + }, + "translucency": { + "enabled": false, + "value": 0.5 + }, + "specular": false, + "position": { + "scale": 0.84, + "translation-in-points": [ + 0, + -112.0 + ] + } + }, + { + "name": "Sheet", + "layers": [ + { + "name": "Sheet", + "image-name": "sheet.svg", + "glass": false, + "fill-specializations": [ + { + "value": { + "solid": "srgb:0.96471,0.49020,0.34118,1.00000" + } + }, + { + "appearance": "tinted", + "value": { + "solid": "srgb:0.50000,0.50000,0.50000,1.00000" + } + } + ] + } + ], + "shadow": { + "kind": "none", + "opacity": 0.5 + }, + "translucency": { + "enabled": false, + "value": 0.5 + }, + "specular": false, + "position": { + "scale": 0.84, + "translation-in-points": [ + 0, + -112.0 + ] + } + } + ], + "supported-platforms": { + "squares": [ + "macOS" + ] + }, + "fill-specializations": [ + { + "value": { + "solid": "srgb:0.15294,0.15294,0.18039,1.00000" + } + }, + { + "appearance": "dark", + "value": { + "solid": "srgb:0.15294,0.15294,0.18039,1.00000" + } + } + ] +} \ No newline at end of file diff --git a/apps/maple-agent/app/packaging/icon/prod/MapleAgent.icon/Assets/m.svg b/apps/maple-agent/app/packaging/icon/prod/MapleAgent.icon/Assets/m.svg new file mode 100644 index 000000000..7cdc4580a --- /dev/null +++ b/apps/maple-agent/app/packaging/icon/prod/MapleAgent.icon/Assets/m.svg @@ -0,0 +1 @@ + diff --git a/apps/maple-agent/app/packaging/icon/prod/MapleAgent.icon/Assets/sheet.svg b/apps/maple-agent/app/packaging/icon/prod/MapleAgent.icon/Assets/sheet.svg new file mode 100644 index 000000000..72a99a543 --- /dev/null +++ b/apps/maple-agent/app/packaging/icon/prod/MapleAgent.icon/Assets/sheet.svg @@ -0,0 +1 @@ + diff --git a/apps/maple-agent/app/packaging/icon/prod/MapleAgent.icon/icon.json b/apps/maple-agent/app/packaging/icon/prod/MapleAgent.icon/icon.json new file mode 100644 index 000000000..679fcef92 --- /dev/null +++ b/apps/maple-agent/app/packaging/icon/prod/MapleAgent.icon/icon.json @@ -0,0 +1,92 @@ +{ + "fill-specializations": [ + { + "value": { + "solid": "srgb:0.96863,0.96863,0.97647,1.00000" + } + }, + { + "appearance": "dark", + "value": { + "solid": "srgb:0.15294,0.15294,0.18039,1.00000" + } + } + ], + "groups": [ + { + "name": "M", + "layers": [ + { + "name": "M", + "image-name": "m.svg", + "glass": false, + "fill-specializations": [ + { + "value": { + "solid": "srgb:0.15294,0.15294,0.18039,1.00000" + } + }, + { + "appearance": "dark", + "value": { + "solid": "srgb:0.96863,0.96863,0.97647,1.00000" + } + }, + { + "appearance": "tinted", + "value": { + "solid": "srgb:1.00000,1.00000,1.00000,1.00000" + } + } + ] + } + ], + "shadow": { + "kind": "none", + "opacity": 0.5 + }, + "translucency": { + "enabled": false, + "value": 0.5 + }, + "specular": false + }, + { + "name": "Sheet", + "layers": [ + { + "name": "Sheet", + "image-name": "sheet.svg", + "glass": false, + "fill-specializations": [ + { + "value": { + "solid": "srgb:0.96471,0.49020,0.34118,1.00000" + } + }, + { + "appearance": "tinted", + "value": { + "solid": "srgb:0.50000,0.50000,0.50000,1.00000" + } + } + ] + } + ], + "shadow": { + "kind": "none", + "opacity": 0.5 + }, + "translucency": { + "enabled": false, + "value": 0.5 + }, + "specular": false + } + ], + "supported-platforms": { + "squares": [ + "macOS" + ] + } +} \ No newline at end of file diff --git a/apps/maple-agent/app/packaging/maple-agent-dev.car b/apps/maple-agent/app/packaging/maple-agent-dev.car new file mode 100644 index 000000000..2cba137e7 Binary files /dev/null and b/apps/maple-agent/app/packaging/maple-agent-dev.car differ diff --git a/apps/maple-agent/app/packaging/maple-agent-dev.icns b/apps/maple-agent/app/packaging/maple-agent-dev.icns index 1ca116707..1769db57a 100644 Binary files a/apps/maple-agent/app/packaging/maple-agent-dev.icns and b/apps/maple-agent/app/packaging/maple-agent-dev.icns differ diff --git a/apps/maple-agent/app/packaging/maple-agent-dev.ico b/apps/maple-agent/app/packaging/maple-agent-dev.ico index 5ecfff074..816c5a3d1 100644 Binary files a/apps/maple-agent/app/packaging/maple-agent-dev.ico and b/apps/maple-agent/app/packaging/maple-agent-dev.ico differ diff --git a/apps/maple-agent/app/packaging/maple-agent-dev.png b/apps/maple-agent/app/packaging/maple-agent-dev.png index 5b14c6d44..23473869b 100644 Binary files a/apps/maple-agent/app/packaging/maple-agent-dev.png and b/apps/maple-agent/app/packaging/maple-agent-dev.png differ diff --git a/apps/maple-agent/app/packaging/maple-agent.car b/apps/maple-agent/app/packaging/maple-agent.car new file mode 100644 index 000000000..d7c130ad7 Binary files /dev/null and b/apps/maple-agent/app/packaging/maple-agent.car differ diff --git a/apps/maple-agent/app/packaging/maple-agent.icns b/apps/maple-agent/app/packaging/maple-agent.icns index 60d7aa988..620d38aa8 100644 Binary files a/apps/maple-agent/app/packaging/maple-agent.icns and b/apps/maple-agent/app/packaging/maple-agent.icns differ diff --git a/apps/maple-agent/app/packaging/maple-agent.ico b/apps/maple-agent/app/packaging/maple-agent.ico index be473a607..6be084284 100644 Binary files a/apps/maple-agent/app/packaging/maple-agent.ico and b/apps/maple-agent/app/packaging/maple-agent.ico differ diff --git a/apps/maple-agent/app/packaging/maple-agent.png b/apps/maple-agent/app/packaging/maple-agent.png index 9e03e31f1..0f3373db7 100644 Binary files a/apps/maple-agent/app/packaging/maple-agent.png and b/apps/maple-agent/app/packaging/maple-agent.png differ diff --git a/apps/maple-agent/docs/brand.md b/apps/maple-agent/docs/brand.md index 0a8a4d009..b015703ca 100644 --- a/apps/maple-agent/docs/brand.md +++ b/apps/maple-agent/docs/brand.md @@ -153,7 +153,19 @@ rgba(0,0,0,.1)`. Active: scale 0.95. Disabled: 40 % opacity. Transition `#9c9dab` at 90 % opacity, white glyph centred; sizes 120, 80, 56, 40, 32 px (the 32 px size uses the single "M" chevron). - Favicon 16 px (radius 4) and icon 32 px (radius 8) are a white "M" on - Pebble 800; the 64 px app icon (radius 14) uses the avatar gradient. + Pebble 800. +- App icon, from the App Icons board of the Figma file "Maple Brand Kit" + (https://www.figma.com/design/d5qqJPUb8fNHDsBBLbfOf2): Maple Work stacks + an Ink `#27272e` M on a Maple orange `#f67d57` copy of itself, offset + 15.6/128 down and right, on a Cloud `#f7f7f9` tile. The M is the + wordmark's, 66/128 of the tile wide. Windows and Linux round the tile + at 29/128; macOS applies its own mask. Dark mode turns the tile + Graphite `#27272e` and the M Cloud; the tinted and clear styles keep + the M brightest and the sheet a lighter tone than the tile. Dev builds + shrink the mark to 84 %, with a Cloud M on the Graphite tile, above a + Warning `#d4a35a` "DEV" pill. The sources are Icon Composer documents + in `app/packaging/icon/`, and `scripts/app-icons.py` builds every + platform's icon from them. ## Part 2: how the app applies it diff --git a/apps/maple-agent/scripts/app-icons.py b/apps/maple-agent/scripts/app-icons.py new file mode 100755 index 000000000..ee316b0bb --- /dev/null +++ b/apps/maple-agent/scripts/app-icons.py @@ -0,0 +1,225 @@ +#!/usr/bin/env python3 +"""Rebuild the Work app icons in app/packaging from their Icon Composer sources. + +app/packaging/icon//MapleAgent.icon is the artwork; open it in Icon +Composer to change it. For macOS, Xcode's actool compiles it to the asset +catalog that macOS 26 draws in every icon style (default, dark, tinted, +clear), with flattened copies for earlier releases, and the .icns the bundle +names as its fallback. Windows and Linux get flat rasters drawn from the same +layers in their default appearance; their trays scale the .png. Packaging only +copies the files written here, so commit them with the sources. + +actool stamps each build of the catalog, so a rebuild with unchanged artwork +still changes the .car files; commit them only with an artwork change. + +Needs macOS with Xcode 26 or later, and rsvg-convert (Homebrew librsvg). +""" + +import json +from pathlib import Path +import plistlib +import re +import shutil +import struct +import subprocess +import sys +import tempfile +import xml.etree.ElementTree as ElementTree + +COMPONENT = Path(__file__).resolve().parent.parent +PACKAGING = COMPONENT / "app/packaging" +SOURCES = PACKAGING / "icon" +PROFILES = {"prod": "maple-agent", "dev": "maple-agent-dev"} # output stem per release profile +# CFBundleIconName; release-info.py names the same icon for both profiles. +ICON_NAME = "MapleAgent" +# The bundle's LSMinimumSystemVersion, so the catalog carries fallbacks for it. +MINIMUM_MACOS = "15.0" +ICO_SIZES = (16, 24, 32, 48, 64, 256) +PNG_SIZE = 512 +# Windows and Linux draw icons unmasked, so their tile carries the brand kit's +# rounded corners (29 of 128) and fills the frame, as in the kit, which keeps +# the mark as large as it can be at 16 to 32 px. +TILE_RADIUS = 29 / 128 +CANVAS = 1024 # Icon Composer's canvas, in points +SVG = '{1}\n' + + +def color(value): + """Return (#rrggbb, alpha) for an Icon Composer sRGB colour string.""" + match = re.fullmatch(r"srgb:([0-9.]+),([0-9.]+),([0-9.]+),([0-9.]+)", value) + if not match: + raise ValueError(f"only srgb colours are supported, not {value!r}") + red, green, blue, alpha = (float(component) for component in match.groups()) + return "#" + "".join(f"{round(channel * 255):02X}" for channel in (red, green, blue)), alpha + + +def base_value(entry, key): + """The default-appearance value of `key` or of `key`-specializations.""" + if key in entry: + return entry[key] + for specialization in entry.get(f"{key}-specializations", ()): + if not {"appearance", "idiom", "localization"} & specialization.keys(): + return specialization["value"] + return None + + +def solid(fill): + if not isinstance(fill, dict) or set(fill) != {"solid"}: + raise ValueError(f"only solid fills are supported, not {fill!r}") + return color(fill["solid"]) + + +def layer_paths(svg_path): + """Path data and fill rules of a single-colour SVG layer, and its viewBox. + + Icon Composer places a layer at its own size, centred, so each layer is + drawn on the full canvas and placed with the group's position instead. + """ + root = ElementTree.parse(svg_path).getroot() + if root.get("width") != str(CANVAS) or root.get("height") != str(CANVAS) or not root.get("viewBox"): + raise ValueError(f"{svg_path} must be {CANVAS}x{CANVAS} with a viewBox") + # Icon Composer draws any SVG; the flat icons read only plain paths, so refuse the rest. + unsupported = [child.tag.rpartition("}")[2] for child in root + if child.tag != "{http://www.w3.org/2000/svg}path" or child.get("transform") or len(child)] + if root.get("transform"): + unsupported.insert(0, "svg") + if unsupported: + raise ValueError(f"{svg_path} may hold only elements without transforms, not {unsupported}") + if any(not child.get("d") for child in root): + raise ValueError(f"{svg_path} has a without path data") + view_box = [float(number) for number in root.get("viewBox", "").split()] + paths = [(element.get("d"), element.get("fill-rule", "nonzero")) for element in root] + if not paths: + raise ValueError(f"{svg_path} has no paths") + return view_box, paths + + +# A placement (sx, sy, tx, ty) maps a point (x, y) to (sx * x + tx, sy * y + ty). +IDENTITY = (1.0, 1.0, 0.0, 0.0) + + +def then(outer, inner): + """The placement that applies `inner`, then `outer`.""" + return (outer[0] * inner[0], outer[1] * inner[1], outer[0] * inner[2] + outer[2], outer[1] * inner[3] + outer[3]) + + +def position(entry): + """Icon Composer scales a group or layer about the canvas centre, then moves it in points.""" + value = base_value(entry, "position") + if not value: + return IDENTITY + scale = value["scale"] + dx, dy = value["translation-in-points"] + shift = CANVAS / 2 * (1 - scale) + return (scale, scale, shift + dx, shift + dy) + + +def layers(icon): + """Yield (placement, paths, colour, alpha) back to front, in the default appearance.""" + document = json.loads((icon / "icon.json").read_text(encoding="utf-8")) + for group in reversed(document["groups"]): + if base_value(group, "hidden"): + continue + group_opacity = base_value(group, "opacity") + for layer in reversed(group["layers"]): + if base_value(layer, "hidden"): + continue + (vx, vy, vw, vh), paths = layer_paths(icon / "Assets" / layer["image-name"]) + fit = (CANVAS / vw, CANVAS / vh, -vx * CANVAS / vw, -vy * CANVAS / vh) + fill = base_value(layer, "fill") + if not fill: + # Without one Icon Composer keeps the artwork's colours, which the flat icons can't. + raise ValueError(f"layer {layer['name']!r} needs a solid fill for the Windows and Linux icons") + hex_color, alpha = solid(fill) + opacity = base_value(layer, "opacity") + yield (then(position(group), then(position(layer), fit)), paths, hex_color, + alpha * (1.0 if opacity is None else opacity) * (1.0 if group_opacity is None else group_opacity)) + + +def background(icon): + document = json.loads((icon / "icon.json").read_text(encoding="utf-8")) + return solid(base_value(document, "fill")) + + +def path_elements(items): + out = [] + for (sx, sy, tx, ty), paths, hex_color, opacity in items: + for data, rule in paths: + out.append(f'') + return "".join(out) + + +def flat_svg(icon): + """The default appearance on the kit's rounded tile, for Windows and Linux.""" + tile, tile_alpha = background(icon) + return SVG.format(CANVAS, f'' + f'' + f'{path_elements(layers(icon))}') + + +def rasterize(svg, size, work): + source = work / "artwork.svg" + source.write_text(svg, encoding="utf-8") + output = work / f"artwork-{size}.png" + subprocess.run(["rsvg-convert", "--width", str(size), "--height", str(size), "--output", str(output), str(source)], check=True) + return output.read_bytes() + + +def ico(frames): + """An ICO with one PNG frame per size (Windows Vista and later).""" + if not all(1 <= size <= 256 for size, _ in frames): + raise ValueError("ICO frames must be 1 to 256 px") + header = struct.pack("