Andee lives on your phone or Mac and uses any app like you do—no integrations, no root, any model; memory and passwords never leave your device | Andee 住进你的手机或 Mac,像你一样操作任何 App——无需集成、无需 Root、支持任意模型,记忆和密码绝不离开设备。
feat(brand): make the launcher icon the thinking face, on white
booboosui12b34592c204
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webpindex e7eea44..0a9e008 100644Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.webp and b/app/src/main/res/mipmap-hdpi/ic_launcher.webp differdiff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_background.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_background.webpindex 18b8fe1..2c0847e 100644Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_background.webp and b/app/src/main/res/mipmap-hdpi/ic_launcher_background.webp differdiff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webpindex b60a88b..1169b53 100644Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp and b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp differdiff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_monochrome.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_monochrome.webpindex d1d9a14..2a8636a 100644Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_monochrome.webp and b/app/src/main/res/mipmap-hdpi/ic_launcher_monochrome.webp differdiff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webpindex a8654ad..c3dc359 100644Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differdiff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webpindex da3c375..ac06fab 100644Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.webp and b/app/src/main/res/mipmap-mdpi/ic_launcher.webp differdiff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_background.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_background.webpindex 9d13a0f..92e3a1a 100644Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_background.webp and b/app/src/main/res/mipmap-mdpi/ic_launcher_background.webp differdiff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webpindex f8a6f7f..6fdedd4 100644Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp and b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp differdiff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_monochrome.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_monochrome.webpindex 6a68ff1..72f8586 100644Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_monochrome.webp and b/app/src/main/res/mipmap-mdpi/ic_launcher_monochrome.webp differdiff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webpindex bacd77e..fa7ac2c 100644Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differdiff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webpindex b3471d4..5d5d202 100644Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp and b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differdiff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_background.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_background.webpindex b85e95b..d0f3046 100644Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_background.webp and b/app/src/main/res/mipmap-xhdpi/ic_launcher_background.webp differdiff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webpindex e6eae51..dd43592 100644Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp and b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp differdiff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.webpindex b11dc60..c3db2b6 100644Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.webp and b/app/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.webp differdiff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webpindex 4b23943..4de3e95 100644Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differdiff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webpindex 44ae744..6ed5445 100644Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differdiff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_background.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_background.webpindex 197615e..a49f6d4 100644Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_background.webp and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_background.webp differdiff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webpindex 5607558..a6c169a 100644Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp differdiff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.webpindex 5c3509c..26aa5e6 100644Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.webp and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.webp differdiff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webpindex f8f5874..4658cb1 100644Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differdiff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webpindex 5f576a4..558697f 100644Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differdiff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_background.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_background.webpindex baa9bb5..d43e8c6 100644Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_background.webp and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_background.webp differdiff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webpindex fa1ad4e..6ef01b4 100644Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp differdiff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.webpindex 24d8f39..abc6099 100644Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.webp and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.webp differdiff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webpindex f6de87d..73a997f 100644Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differdiff --git a/tools/andee_head.py b/tools/andee_head.pyindex 4529a87..6be12ae 100644--- a/tools/andee_head.py+++ b/tools/andee_head.py@@ -1,8 +1,14 @@#!/usr/bin/env python3-"""从 images/brand/andee-head.png 取出角色:头部抠图、五官遮罩、光晕底片。+"""从品牌美术稿里取出角色:头部抠图、五官遮罩、光晕底片。-源图是一张**不透明**的方图:白底,头部外面一圈橙→粉的光晕,头部本身是蓝色。-没有 alpha,所以这里要自己抠 —— 抠法是量出来的,不是调出来的:+两种源图,两条路:++ * `images/brand/andee-head.png`(**不透明**)—— 白底 + 橙粉光晕 + 蓝色头部,+ 走 `character_rgba()`:自己抠。+ * `images/brand/illustrations/*.webp`(**自带 alpha**)—— 已经抠好的插画,+ 走 `alpha_source()`:直接用它的 alpha,但必须先清掉 lossy WebP 的抖动噪声。++第一条路(不透明源)的抠法是量出来的,不是调出来的:* 光晕和头部在**色相**上是分开的:光晕的 R 通道约 253,头部的 R 在 27–110。光晕环 = `R-G > 14 且 R-B > -5`,它把头部整圈包住,所以"光晕环内侧、与头部@@ -162,6 +168,217 @@ def circumcircle(alpha: np.ndarray, thr: float = 0.03):return best+# ================================================================ 自带 alpha 的插画+#+# think.webp / wink.webp 这一类是**已经抠好**的插画(直通 alpha,实测:把半透明的+# 边缘像素按直通和按预乘各解释一遍,直通与内侧实心邻居的色差 45.8,预乘 112.9,+# 分辨力 2.46×)。所以不再需要 head_matte。+#+# 但它是 **lossy WebP**:全画布 9.6% 的像素带着 alpha 1–7 的抖动噪声散在四角。+# 不清掉的话,底片上会浮一层几乎看不见但洗不掉的灰纱,而且"主体外接圆"会被这些+# 角落噪点撑到整张画布。噪声上限与真实边缘之间是空的(alpha=1 占 21919px,+# alpha=2 起断崖),所以砍在 8。+ALPHA_FLOOR = 8+++def alpha_source(path) -> tuple:+ """自带 alpha 的插画 -> (rgb, alpha[0..1])。alpha 走直通,RGB 原样。"""+ a = np.asarray(Image.open(path).convert("RGBA")).astype(np.float64)+ al = a[..., 3]+ return a[..., :3].copy(), np.where(al < ALPHA_FLOOR, 0.0, al / 255.0)+++def ball_fit(hard: np.ndarray) -> tuple:+ """主体里那个"球"的圆心与半径 —— 光晕是以球为光源向外发的。++ 取**最宽的一行**当赤道:角长在球顶、手压在球底,都比球窄,所以最宽行一定是+ 球本身。拿它当光源中心,光晕才是绕着球的一圈,而不是绕着"外接圆"的一圈+ (外接圆被头顶的角撑大、被手往下拽,用它做极坐标会让光晕歪掉)。+ """+ ys = np.where(hard.any(axis=1))[0]+ best = (-1, 0, 0, 0)+ for y in ys:+ xs = np.where(hard[y])[0]+ w = xs.max() - xs.min() + 1+ if w > best[0]:+ best = (w, y, xs.min(), xs.max())+ w, cy, x0, x1 = best+ return (x0 + x1) / 2.0, float(cy), w / 2.0+++def _circ_smooth(tab: np.ndarray, sigma_deg: float) -> np.ndarray:+ """把一张 360×3 的方位表按角度做环形高斯平滑。"""+ sd = max(sigma_deg, 1e-3)+ half = int(3.0 * sd)+ k = np.exp(-0.5 * (np.arange(-half, half + 1) / sd) ** 2)+ k /= k.sum()+ ext = np.vstack([tab[-half:], tab, tab[:half]])+ return np.stack([np.convolve(ext[:, c], k, "same")[half:-half] for c in range(3)], axis=1)+++def rim_glow(rgb: np.ndarray, hard: np.ndarray, ball: tuple, fade_px: float,+ white: float = 254.0, band=(2.0, 9.0), warm_floor: float = -6.0,+ saturate: float = 1.2, smooth_deg: float = 20.0) -> np.ndarray:+ """用**球自己的边缘光**当底片:在球的边缘按方位取一条色环,再向外化白。++ 和 andee-head 那条路(`glow_background`)要的是同一个东西:底片就是角色周围+ 那圈光的延续,这样图标和封面看起来是同一张画。区别是源图自带 alpha 之后,+ 球外面什么都没有可补 —— 能补的只有**球自己边上的那圈光**。++ 五个必须做的判断:++ * **取样带必须贴边**(默认 R−2 到 R−9)。边缘光是**很薄的一层**:沿半径实测+ 175° 是 −2:(246,174,144) 暖橙 → −5:(255,252,238) 白高光 → −12:(251,227,233)。+ 取到 −14 就把球身内侧的白高光一起平均进来,底片会淡成一层洗不掉的灰粉。+ * **被挡住方位不采信。** 头顶的角、球底的手压在球的边缘上,那些方位的+ "球边缘像素"其实是角/手的颜色。判据是"这条射线上的剪影外沿是不是就落在+ 球边附近",不是就跳过,缺口按方位插值补。+ * **只要暖的那半边。** 球顶 60–120° 的边缘实测是 (174,211,250) 一类浅蓝 ——+ 那是**顶光打在球面上的高光**,不是角色周围的那圈暖光。照单全收球顶会顶出+ 一圈冷蓝,整个图标发灰。判据用 R−B(暖为正):暖样本在 −4 以上、冷样本在+ −28 以下,取 −6;深蓝的描边(36,79,151)也被它滤掉。+ * **方位上要抹得很平。** 边缘光是**贴在球面上**的,相邻方位的色差会被径向拉+ 成从中心甩出来的放射条纹("色轮")。±6° 只够去掉插值接缝,实测要+ sigma≈20° 才看不出条纹。代价是幅值也被平滑吃掉一部分(实测方位均值+ 只剩 (238,202,209),比旧底片的 (253,192,188) 淡),所以再用 `saturate`+ 放大回去 —— 1.2 时球边上是 (234,196,198),和旧图标是同一档浓度。+ * **化白长度按画布比例给**,不是按源图像素给 —— fade_px 由调用方按+ `比例 × 画布 / scale` 算出来,换个源图分辨率不用改这里。+ """+ H, W = hard.shape+ yy, xx = np.mgrid[0:H, 0:W]+ dx, dy = xx - ball[0], yy - ball[1]+ r = np.hypot(dx, dy)+ th = (np.degrees(np.arctan2(-dy, dx)) + 360.0) % 360.0+ idx = np.floor(th).astype(int) % 360++ outside = r > ball[2] + 6.0+ rim_outer = np.full(360, -1.0)+ hit = hard & outside+ for t in range(360):+ sel = hit & (idx == t)+ if sel.any():+ rim_outer[t] = r[sel].max()++ lo, hi = ball[2] - band[1], ball[2] - band[0]+ annular = hard & (r >= lo) & (r <= hi)+ tab = np.zeros((360, 3))+ have = np.zeros(360, bool)+ for t in range(360):+ if rim_outer[t] > 0: # 球外还有东西 ⇒ 球边被挡住,不采信+ continue+ sel = annular & (idx == t)+ if sel.sum() >= 3:+ cols = rgb[sel]+ warm = cols[(cols[:, 0] - cols[:, 2]) >= warm_floor]+ if len(warm) >= 3:+ tab[t] = np.median(warm, axis=0)+ have[t] = True+ if have.sum() < 120:+ raise SystemExit(f"球的边缘光只采到 {int(have.sum())}/360 个方位,先看 ball_fit。")++ filled = tab.copy()+ for t in range(360):+ if have[t]:+ continue+ for k in range(1, 180):+ a, b = (t - k) % 360, (t + k) % 360+ if have[a] and have[b]:+ filled[t] = (tab[a] + tab[b]) / 2.0+ break+ if have[a]:+ filled[t] = tab[a]+ break+ if have[b]:+ filled[t] = tab[b]+ break++ smooth = _circ_smooth(filled, smooth_deg)+ edge = white + (smooth - white) * saturate++ d = np.clip(r - ball[2], 0.0, None)+ t = np.clip(d / fade_px, 0.0, 1.0)+ t = t * t * (3.0 - 2.0 * t) # smoothstep:贴球处最浓,往外很快化白+ return np.clip(edge[idx] * (1.0 - t[..., None]) + white * t[..., None], 0, 255)+++def components(mask: np.ndarray, min_px: int = 1):+ """4 邻域连通域,返回 [[(y,x), ...], ...]。不引 scipy —— 这个仓库的图片工具链+ 只依赖 numpy + PIL。"""+ H, W = mask.shape+ seen = np.zeros((H, W), bool)+ out = []+ ys, xs = np.where(mask)+ for y0, x0 in zip(ys, xs):+ if seen[y0, x0]:+ continue+ seen[y0, x0] = True+ stack = [(y0, x0)]+ px = []+ while stack:+ y, x = stack.pop()+ px.append((y, x))+ for ny, nx in ((y - 1, x), (y + 1, x), (y, x - 1), (y, x + 1)):+ if 0 <= ny < H and 0 <= nx < W and mask[ny, nx] and not seen[ny, nx]:+ seen[ny, nx] = True+ stack.append((ny, nx))+ if len(px) >= min_px:+ out.append(px)+ return out+++def holes_from_dark(lum: np.ndarray, subject: np.ndarray, thr: float,+ min_eye: int = 1500, min_mouth: int = 300, grow: float = 1.04):+ """五官镂空,给单色(主题)图标用。按**连通域大小**分,不按坐标分。++ 阈值必须落在实测的亮度谷底里:think.webp 的主体亮度 [40,70) 是谷(每格+ 275–393px),球身从 80 起堆量。取 55。++ 分法是量出来的:眼睛 3724 / 3481px,嘴 498px,其余 115 个连通域全都 < 30px+ (角的描边、手的指缝)。中间是数量级的空档,所以"最大的两个 = 眼睛、剩下的+ 最大 = 嘴"是稳的 —— 换成"y 坐标在某个范围"就会换个姿势就崩。++ 眼睛用 bbox 拟合椭圆(眼球里的高光点比周围亮,阈值 mask 会在洞里留一个疙瘩),+ 嘴用真实暗像素做闭运算(嘴是两端收细的弧,椭圆会把球身一起拖进来)。+ """+ H, W = lum.shape+ yy, xx = np.mgrid[0:H, 0:W]+ dark = subject & (lum < thr)+ cs = components(dark)+ cs.sort(key=len, reverse=True)+ eyes = [c for c in cs if len(c) >= min_eye]+ if len(eyes) != 2:+ raise SystemExit(f"眼睛找到 {len(eyes)} 个(阈值 {thr}),先量亮度直方图的谷底。")+ rest = [c for c in cs if min_mouth <= len(c) < min_eye]+ if len(rest) != 1:+ raise SystemExit(f"嘴找到 {len(rest)} 个:先看连通域大小的空档,再调 min_mouth。")+ mouth_px = rest[0]++ holes = np.zeros((H, W), bool)+ boxes = []+ for px in eyes:+ ys = [p[0] for p in px]+ xs = [p[1] for p in px]+ x0, x1 = np.percentile(xs, [0.5, 99.5])+ y0, y1 = np.percentile(ys, [0.5, 99.5])+ ex, ey = (x0 + x1) / 2.0, (y0 + y1) / 2.0+ ax, ay = (x1 - x0 + 1) / 2.0 * grow, (y1 - y0 + 1) / 2.0 * grow+ holes |= ((xx - ex) / ax) ** 2 + ((yy - ey) / ay) ** 2 <= 1.0+ boxes.append((x0, y0, x1, y1))++ mouth = np.zeros((H, W), bool)+ for y, x in mouth_px:+ mouth[y, x] = True+ for _ in range(2):+ mouth = mouth | np.roll(mouth, 1, 0) | np.roll(mouth, -1, 0) | \+ np.roll(mouth, 1, 1) | np.roll(mouth, -1, 1)+ for _ in range(2):+ mouth = mouth & np.roll(mouth, 1, 0) & np.roll(mouth, -1, 0) & \+ np.roll(mouth, 1, 1) & np.roll(mouth, -1, 1)+ holes |= mouth & subject+ return holes, boxes, mouth++if __name__ == "__main__":rgba, alpha, hard, a = character_rgba()ys, xs = np.where(alpha > 0.03)diff --git a/tools/make_launcher_icon.py b/tools/make_launcher_icon.pyindex bcbfe66..67d1741 100644--- a/tools/make_launcher_icon.py+++ b/tools/make_launcher_icon.py@@ -1,15 +1,28 @@#!/usr/bin/env python3-"""从 images/brand/andee-head.png 生成整套 Android 启动图标。+"""从一张品牌美术稿生成整套 Android 启动图标。-源图是不透明的(白底 + 橙粉光晕 + 蓝色头部),抠图与五官遮罩在-`andee_head.py`;这里只管"怎么摆到各个图层里"。+源图有两种,自动分派:++ * **自带 alpha 的插画**(`images/brand/illustrations/*.webp`,默认):已经抠好的+ 直通 alpha,直接当剪影用。+ * **不透明的整图画稿**(`images/brand/andee-head.png`):白底+光晕,得自己抠+ (`andee_head.py`)。++判据就是源图的 mode 有没有 alpha —— 不是文件名。++## 底片(`--bg`)++默认**纯白** `#ffffff` —— 这些插画本来就是画在白底上的,角色边缘那圈暖光是画在+它自己身上的,放回白底就等于放回原画的底,不会引入任何推出来的颜色。++`--bg glow` 换回 2026-10-14 之前的暖光晕:不自绘,从角色**自己的边缘光**推出来+(`rim_glow`:贴球取色环 → 向外化白)。它要处理三件事,都在 `rim_glow` 的注释里。+默认之所以不是它:光晕是"推"出来的,白底是"原画本来就有"的。## 四种图* `ic_launcher_foreground` 自适应前景:抠出的角色,透明底- * `ic_launcher_background` 自适应背景:**源图自己的光晕**,头部那块用周围的- 光晕补平(push-pull 式的归一化卷积)。不是另画一张渐变 —— 图标和封面要- 看起来是同一张画,所以用同一份光晕+ * `ic_launcher_background` 自适应背景:`--bg` 决定(默认纯白)* `ic_launcher_monochrome` 主题图标:黑 = 实体,透明 = 镂空,眼睛和嘴是洞* `ic_launcher` / `_round` 传统光栅图(API < 26 与部分启动器):背景 + 角色合成,圆形版加圆遮罩@@ -20,16 +33,19 @@offset 变换过去 —— 每层各缩一次会让单色层的眼睛洞和前景的眼睛差 1px,432px上看不出,108px 上一眼就歪。-**外接圆决定大小。** 系统把画布中央 72/108 当保证可见的圆。角伸在头外,外接圆-比头大;把角色整体下移到"到画布中心的最大距离"最小,再把这个距离缩到可见圆半径-的 `CONTENT` 倍。角永远不会被圆形遮罩切到。+**外接圆决定大小。** 系统把画布中央 72/108 当保证可见的圆。角伸在头外、手伸在+球下,外接圆比球大;把角色整体下移到"到画布中心的最大距离"最小,再把这个距离+缩到可见圆半径的 `CONTENT` 倍。**沿用旧图的比例,所以换图不会改变图标在桌面上+的视觉大小。** 角/手永远不会被圆形遮罩切到。传统图单独构建(同样按外接圆,占圆形的 `LEGACY_CONTENT`),不从自适应画布缩下来 —— 那样会把为遮罩预留的那圈死边一起缩进去,48px 上就是一张贴纸。用法:- python3 tools/make_launcher_icon.py # 写 app/src/main/res/mipmap-*- python3 tools/make_launcher_icon.py --dump /tmp/x # 另存背景 / 前景大图核对+ python3 tools/make_launcher_icon.py # 默认 think.webp -> mipmap-*+ python3 tools/make_launcher_icon.py --bg glow # 换回暖光晕底片+ python3 tools/make_launcher_icon.py --src <图> --dump /tmp/x+ python3 tools/make_launcher_icon.py --content 0.92 # 角色小一圈(乘在基准上)"""import argparseimport sys@@ -46,6 +62,12 @@ ADAPTIVE_DP = 108.0LEGACY_DP = 48.0VISIBLE_FRACTION = 72.0 / 108.0+REPO = Path(__file__).resolve().parent.parent+DEFAULT_SRC = REPO / "images" / "brand" / "illustrations" / "think.webp"++# 底片默认纯白。改成 "glow" 就走 `rim_glow` 那套推出来的暖光晕。+BG_DEFAULT = "#ffffff"+# 角色外接圆半径 / 可见圆半径。小于 1 是给光晕留出看得见的一圈 —— 角色占满可见圆# 的话,背景只剩一道细边,等于白做。CONTENT = 0.86@@ -53,6 +75,15 @@ CONTENT = 0.86# 角不被切。LEGACY_CONTENT = 0.90+# 只在 `--bg glow` 时用到:底片从角色边上化到纯白所经过的距离,按**画布**比例给+# (0.175 ≈ 旧图标量出来的 75px/432px)。换成源图像素就是 比例 × 画布 / scale,+# 见 main() 里对 fade_src 的算法。+GLOW_FADE_FRACTION = 0.175+# 五官亮度阈值。两条路各自量过:不透明源 50(瞳孔 0–33 / 球身 70–140),+# 自带 alpha 的插画 55(谷底在 [40,70))。+DARK_LUM = 50.0+DARK_LUM_ALPHA = 55.0+SHARPEN_PERCENT = 40@@ -165,23 +196,92 @@ def webp(im: Image.Image, path: Path):# ---------------------------------------------------------------- 主流程+def load_subject(src: Path):+ """源图 -> 摆放图层需要的一切。两条路在这里分,下面完全共用。++ 返回 dict: rgba(合成好的角色) / alpha / holes(五官镂空) / a(源分辨率 RGBA 浮点)+ / hard / ball(球心与半径,只有 rim 这条路上有) / glow("rim" | "halo")+ """+ if Image.open(src).mode in ("RGBA", "LA", "PA"):+ rgb, alpha = head.alpha_source(src)+ hard = alpha > 0.5+ lum = head.luminance(rgb)+ holes, boxes, _ = head.holes_from_dark(lum, hard, DARK_LUM_ALPHA)+ ball = head.ball_fit(hard)+ rgba = np.dstack([np.clip(rgb, 0, 255), alpha * 255.0]).astype(np.uint8)+ a = np.dstack([rgb, alpha * 255.0])+ print(f"源图 {src.name} 自带 alpha 球心 x={ball[0]:.1f} y={ball[1]:.1f} "+ f"半径 {ball[2]:.1f}px")+ return dict(rgba=rgba, alpha=alpha, holes=holes, boxes=boxes,+ a=a, hard=hard, ball=ball, glow="rim")++ rgba, alpha, hard, a = head.character_rgba()+ holes, boxes, _ = head.face_holes(a, hard)+ print(f"源图 {src.name} 不透明 需抠图")+ return dict(rgba=rgba, alpha=alpha, holes=holes, boxes=boxes,+ a=a, hard=hard, ball=None, glow="halo")+++def parse_bg(spec: str):+ """`--bg` 解析:`glow` -> None(走推出来的光晕),`#rrggbb` -> 纯色。"""+ if spec.lower() == "glow":+ return None+ t = spec.lstrip("#")+ if len(t) != 6:+ raise SystemExit(f"--bg 只认 'glow' 或 #rrggbb,收到 {spec!r}")+ try:+ return np.array([int(t[i:i + 2], 16) for i in (0, 2, 4)], dtype=np.float64)+ except ValueError:+ raise SystemExit(f"--bg 只认 'glow' 或 #rrggbb,收到 {spec!r}")+++def build_background(sub, fade_px, saturate, smooth_deg, warm_floor, color):+ if color is not None:+ h, w = sub["hard"].shape+ return np.broadcast_to(color, (h, w, 3)).astype(np.float64)+ if sub["glow"] == "rim":+ return head.rim_glow(sub["a"][..., :3], sub["hard"], sub["ball"], fade_px,+ warm_floor=warm_floor, saturate=saturate,+ smooth_deg=smooth_deg)+ return glow_background(sub["a"], sub["hard"])++def main():ap = argparse.ArgumentParser()+ ap.add_argument("--src", default=str(DEFAULT_SRC), help="品牌美术稿(带 alpha 或整图)")ap.add_argument("--res", default="app/src/main/res")ap.add_argument("--dump", default=None, help="把源分辨率的背景/前景/单色另存到该目录")+ ap.add_argument("--bg", default=BG_DEFAULT, help="底片:'glow' 或 #rrggbb(默认纯白)")ap.add_argument("--content", type=float, default=1.0,help="角色大小因子,乘在 CONTENT / LEGACY_CONTENT 上")+ ap.add_argument("--glow-saturate", type=float, default=1.2,+ help="--bg glow 时边缘光放大多少(1=实测原样,越大越浓)")+ ap.add_argument("--glow-warm", type=float, default=-6.0,+ help="--bg glow 时边缘光采信的 R−B 下限;球顶的冷高光靠它滤掉")+ ap.add_argument("--glow-smooth", type=float, default=20.0,+ help="--bg glow 时边缘光的方位平滑量(度),小了会出放射条纹")args = ap.parse_args()+ bg_color = parse_bg(args.bg)- rgba, alpha, hard, a = head.character_rgba()+ src = Path(args.src)+ sub = load_subject(src)+ alpha, hard = sub["alpha"], sub["hard"]H, W = alpha.shapeccx, ccy = (W - 1) / 2.0, (H - 1) / 2.0opt, dy = head.circumcircle(alpha)- holes, boxes, _ = head.face_holes(a, hard)- print(f"源图 {W}×{H} 外接圆半径 {opt:.1f}px,下移 {dy}px")+ holes = sub["holes"]+ print(f" {W}×{H} 外接圆半径 {opt:.1f}px,下移 {dy}px")- char = Image.fromarray(rgba, "RGBA")- bg_arr = glow_background(a, hard)+ char = Image.fromarray(sub["rgba"], "RGBA")+ content = CONTENT * args.content+ legacy_content = LEGACY_CONTENT * args.content+ # 光晕的化白距离按**画布**比例给,这里折回源图像素:+ # scale = 可见圆半径 × content / opt,而可见圆半径 = 画布 × 72/108/2+ # ⇒ fade_src = 比例 × 画布 / scale = 比例 × opt / (72/108/2 × content)+ # 与密度无关(xxxhdpi 和 mdpi 的 scale 差 4 倍、比例一样),所以只算一次。+ fade_src = GLOW_FADE_FRACTION * opt / (VISIBLE_FRACTION / 2.0 * content)+ bg_arr = build_background(sub, fade_src, args.glow_saturate,+ args.glow_smooth, args.glow_warm, bg_color)bg = Image.fromarray(bg_arr.astype(np.uint8), "RGB")border = np.concatenate([bg_arr[0], bg_arr[-1], bg_arr[:, 0], bg_arr[:, -1]])pad = tuple(int(round(v)) for v in np.median(border, axis=0))@@ -198,8 +298,6 @@ def main():mono_img.save(d / "monochrome.png")res = Path(args.res)- content = CONTENT * args.content- legacy_content = LEGACY_CONTENT * args.contenttotal = 0for name, dpi in DENSITIES:out = res / f"mipmap-{name}"