Files
lotherkandClaude Sonnet 5.5 73c9de51a6 licence: the CNCL line in every file Makronix wrote (tools, docs, www, mobile, top level)
consmirror.c: the BSD notice is replaced (Makronix's own file).  Files with
changes of other sessions pending are left for their commit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 11:50:26 +00:00

68 lines
3.2 KiB
Bash
Executable File

#!/bin/sh
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
# theme-logo.sh -- the Makronix logo in the colours of a CDE palette.
#
# usage: theme-logo.sh PALETTE.dp NAME OUTDIR
# PALETTE.dp a CDE palette (build/obj/destdir.amd64/usr/pkg/dt/share/palettes/*.dp,
# eight lines "#RRRRGGGGBBBB")
# NAME the release name, for the file names: OUTDIR/makronix-NAME.svg
# and OUTDIR/makronix-square-NAME.svg
#
# Release names are CDE palette names (Konrad, 2026-11-08: 0.99.9 is
# "Camouflage"), and a release looks like its palette. docs/logo/makronix.svg
# and makronix-square.svg are the reference in the house blue-violet; this
# script swaps the nine colours that make the tile (the chrome of the letters
# and the dark outline stay) for colours derived from the palette:
#
# slot 5 (the window colour, docs/reference/cde-colours.txt) gives the tile,
# its bevel, the grid and the subline; slot 3 gives the swoosh.
#
# Needs awk and sed. POSIX sh.
set -u
[ $# -eq 3 ] || { echo "usage: ${0##*/} PALETTE.dp NAME OUTDIR" >&2; exit 1; }
dp=$1 name=$2 out=$3
top=$(cd "$(dirname "$0")/.." && pwd)/docs/logo
[ -r "$dp" ] || { echo "${0##*/}: cannot read $dp" >&2; exit 1; }
mkdir -p "$out" || exit 1
# slot N of the palette as 8 bit "R G B" (the high byte of each 16 bit value)
slot()
{
awk -v n="$1" 'NR == n { h = substr($0, 2);
printf "%d %d %d\n", strtonum("0x" substr(h,1,2)), strtonum("0x" substr(h,5,2)), strtonum("0x" substr(h,9,2)) }' "$dp" 2>/dev/null ||
awk -v n="$1" 'function hx(s, i, v, c) { v = 0; s = tolower(s);
for (i = 1; i <= length(s); i++) { c = index("0123456789abcdef", substr(s,i,1)) - 1; v = v * 16 + c }
return v }
NR == n { h = substr($0, 2); printf "%d %d %d\n", hx(substr(h,1,2)), hx(substr(h,5,2)), hx(substr(h,9,2)) }' "$dp"
}
# mix: lighten (toward white) by f, or darken (toward black) when f is negative
mix()
{
echo "$1" | awk -v f="$2" '{ for (i = 1; i <= 3; i++) {
v = ($i + (f >= 0 ? (255 - $i) * f : $i * f));
c[i] = int(v + 0.5) }
printf "#%02x%02x%02x", c[1], c[2], c[3] }'
}
s5=$(slot 5); s3=$(slot 3)
[ -n "$s5" ] && [ -n "$s3" ] || { echo "${0##*/}: $dp is not a palette" >&2; exit 1; }
tile_top=$(mix "$s5" 0.25); tile_mid=$(mix "$s5" -0.15); tile_bot=$(mix "$s5" -0.60)
bev_light=$(mix "$s5" 0.65); bev_dark=$(mix "$s5" -0.75)
grid=$(mix "$s5" 0.45); sub=$(mix "$s5" -0.55)
acc1=$(mix "$s3" 0.55); acc2=$(mix "$s3" 0.10)
ch_hi=$(mix "$s5" 0.85); ch_sky=$(mix "$s5" 0.70); ch_hz=$(mix "$s5" -0.20)
ch_gnd=$(mix "$s5" -0.70); ch_bnc=$(mix "$s5" 0.05); ch_lo=$(mix "$s5" 0.80); line=$(mix "$s5" -0.92)
for f in makronix makronix-square; do
sed -e "s/#6a78e8/$tile_top/g" -e "s/#3a3fb0/$tile_mid/g" -e "s/#1b1c63/$tile_bot/g" \
-e "s/#c9d0ff/$bev_light/g" -e "s/#0d0e3a/$bev_dark/g" -e "s/#8d97ff/$grid/g" \
-e "s/#2a2f8a/$sub/g" -e "s/#ffb347/$acc1/g" -e "s/#ff5e1a/$acc2/g" \
-e "s/#cfd6ee/$ch_sky/g" -e "s/#6f7aa8/$ch_hz/g" -e "s/#1c2048/$ch_gnd/g" \
-e "s/#5865a8/$ch_bnc/g" -e "s/#d6dcf4/$ch_lo/g" -e "s/#06071f/$line/g" \
"$top/$f.svg" > "$out/${f%%-square}${f#makronix}-$name.svg"
done
echo "$out/makronix-$name.svg $out/makronix-square-$name.svg (tile $tile_top $tile_mid $tile_bot)"