From f837201648e8a47af79b08a1a3fedfaf7be547f6 Mon Sep 17 00:00:00 2001 From: daniel wang Date: Mon, 16 Nov 2026 17:05:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=AA=E5=9C=96=E6=A6=82=E5=BF=B5=E8=89=B2?= =?UTF-8?q?=E6=9D=BF=E7=94=A2=E7=94=9F=E5=99=A8=EF=BC=9A=E7=B4=99=EF=BC=8F?= =?UTF-8?q?=E5=A4=9C=EF=BC=8F=E5=A2=A8=EF=BC=8F=E8=8B=94=EF=BC=88ANYBOT=5F?= =?UTF-8?q?SHOT=5FPAL=EF=BC=89=EF=BC=8C=E6=8C=91=E6=96=B9=E5=90=91?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 安靜外殼第一步:先不換預設色,把四套方向用真實聊天畫面渲染出來挑。 每套只有三個輸入(墨色、紙色、accent)加兩個意義色(danger、up), 其餘全部由階梯生成——surface 是紙朝墨走等量小步,文字是墨朝紙退回, chart 六色是 accent 轉色相的低飽和組(Linear 把 98 個手調變數砍成 3 個輸入的做法)。 - 紙:暖米白紙+暖墨+黏土橘 accent(Claude 的調性) - 夜:暖黑底+霧靛藍 accent(Linear 的調性) - 墨:純灰高對比,accent 就是墨本身(ChatGPT 的色盲規則) - 苔:綠灰紙+苔綠 accent(有溫度的一支) 已驗證: cargo test 501 全綠;八張概念圖渲染成功,取樣確認色溫如設計 (紙 247,246,243 暖白/墨 12,12,12 純灰/夜 18,19,20 冷黑/苔 241,243,239 綠白), 高飽和像素每圖約百點=accent 只在小面積出現 未驗證: 實際觀感要人眼挑——這正是這輪的目的,選定後才動預設色板 --- src/app.rs | 6 +++ src/theme.rs | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) diff --git a/src/app.rs b/src/app.rs index 53276fe..f456881 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1164,6 +1164,12 @@ impl App { Theme::System => ctx.input(|i| i.raw.system_theme) == Some(egui::Theme::Dark), }; self.pal = if dark { DARK } else { LIGHT }; + // Screenshot concept themes for picking a colour direction (see theme.rs `shot_palette`). + if let Ok(t) = std::env::var("ANYBOT_SHOT_PAL") { + if let Some(p) = crate::theme::shot_palette(&t, dark) { + self.pal = p; + } + } let p = self.pal; let mut v = if dark { egui::Visuals::dark() } else { egui::Visuals::light() }; v.panel_fill = p.pane; diff --git a/src/theme.rs b/src/theme.rs index a7472b3..1cae311 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -118,3 +118,112 @@ pub fn mist(col: Color32, p: Palette) -> Color32 { let mix = |a: u8, b: u8| (a as f32 + (b as f32 - a as f32) * k).round() as u8; Color32::from_rgb(mix(p.pane.r(), col.r()), mix(p.pane.g(), col.g()), mix(p.pane.b(), col.b())) } + +/// Concept themes for screenshots only (`ANYBOT_SHOT_PAL=paper|night|ink|moss`, with +/// `ANYBOT_SHOT_THEME=dark` for the dark one): the shell is generated from three inputs — +/// one ink, one paper, one accent — the Linear way (98 hand-set colours became 3 inputs). +/// Surfaces are the paper stepped toward the ink in equal little steps; text is the ink +/// faded back from full; colour appears only as the accent and as meaning (danger, up). +/// When a direction is chosen it becomes LIGHT/DARK proper; this stays as the generator seed. +pub fn shot_palette(name: &str, dark: bool) -> Option { + // (ink, paper, accent, danger, up) — the three inputs, plus the two meanings. + let (ink, paper, accent, danger, up) = match (name, dark) { + // 紙: warm ivory page, near-black warm ink, one clay accent (Claude's register). + ("paper", false) => (rgb(0x25, 0x22, 0x1f), rgb(0xfa, 0xf9, 0xf6), rgb(0xc0, 0x62, 0x44), rgb(0xb4, 0x2a, 0x2a), rgb(0x2e, 0x7d, 0x3f)), + ("paper", true) => (rgb(0xf2, 0xf0, 0xeb), rgb(0x1e, 0x1d, 0x1b), rgb(0xd8, 0x83, 0x66), rgb(0xe2, 0x6e, 0x6e), rgb(0x6f, 0xb9, 0x7d)), + // 夜: Linear's warm near-black, one desaturated indigo, everything else grey. + ("night", false) => (rgb(0x20, 0x21, 0x24), rgb(0xf6, 0xf6, 0xf8), rgb(0x5e, 0x6a, 0xd2), rgb(0xc2, 0x37, 0x37), rgb(0x2c, 0x7a, 0x55)), + ("night", true) => (rgb(0xf0, 0xf0, 0xf2), rgb(0x10, 0x11, 0x12), rgb(0x7c, 0x87, 0xe0), rgb(0xe5, 0x73, 0x73), rgb(0x67, 0xb3, 0x8b)), + // 墨: pure monochrome, high contrast — the accent is the ink itself (ChatGPT's rule). + ("ink", false) => (rgb(0x0d, 0x0d, 0x0d), rgb(0xf9, 0xf9, 0xf9), rgb(0x0d, 0x0d, 0x0d), rgb(0x9c, 0x22, 0x22), rgb(0x1d, 0x6b, 0x3a)), + ("ink", true) => (rgb(0xf7, 0xf7, 0xf7), rgb(0x0a, 0x0a, 0x0a), rgb(0xf7, 0xf7, 0xf7), rgb(0xe0, 0x60, 0x60), rgb(0x6c, 0xb7, 0x84)), + // 苔: a green-grey paper, moss accent — the quiet one with a colour temperature. + ("moss", false) => (rgb(0x1f, 0x24, 0x20), rgb(0xf4, 0xf6, 0xf2), rgb(0x4a, 0x7c, 0x59), rgb(0xa9, 0x35, 0x2e), rgb(0x2e, 0x7d, 0x4f)), + ("moss", true) => (rgb(0xec, 0xf0, 0xea), rgb(0x15, 0x18, 0x15), rgb(0x7f, 0xaa, 0x8a), rgb(0xdd, 0x6f, 0x66), rgb(0x76, 0xc0, 0x90)), + _ => return None, + }; + let (accent, focus) = (accent, accent); + // The ladder: every surface is the paper stepped toward the ink; every text is the ink + // stepped back toward the paper. Equal steps are what makes it read as one system. + let step = |k: f32| mix(paper, ink, k); + let six = |l: f32| [hsl_shift(accent, 0.0, 0.52, l), hsl_shift(accent, 52.0, 0.42, l), hsl_shift(accent, 110.0, 0.40, l), hsl_shift(accent, 190.0, 0.45, l), hsl_shift(accent, 265.0, 0.40, l), hsl_shift(accent, 325.0, 0.12, l)]; + let cat = if dark { six(0.62) } else { six(0.48) }; + Some(Palette { + pane: paper, + sidebar: step(0.045), + elevated: if dark { step(0.10) } else { rgb(0xff, 0xff, 0xff) }, + hover: with(ink, 15), + active: with(ink, 26), + primary: ink, + text: ink, + text2: mix(ink, paper, 0.34), + text3: mix(ink, paper, 0.50), + on_primary: paper, + bubble_user: if dark { with(ink, 46) } else { ink }, + border: with(ink, if dark { 26 } else { 20 }), + focus, + accent, + danger, + attention: rgb(0xd9, 0xa4, 0x41), + attention_bg: with(rgb(0xd9, 0xa4, 0x41), if dark { 38 } else { 26 }), + muted: if dark { step(0.10) } else { step(0.035) }, + chart_cat: cat, + grid: with(ink, 14), + up, + }) +} + +const fn rgb(r: u8, g: u8, b: u8) -> Color32 { + Color32::from_rgb(r, g, b) +} + +fn with(c: Color32, a: u8) -> Color32 { + Color32::from_rgba_unmultiplied(c.r(), c.g(), c.b(), a) +} + +fn mix(a: Color32, b: Color32, t: f32) -> Color32 { + let m = |x: u8, y: u8| (x as f32 + (y as f32 - x as f32) * t).round().clamp(0.0, 255.0) as u8; + Color32::from_rgb(m(a.r(), b.r()), m(a.g(), b.g()), m(a.b(), b.b())) +} + +/// The accent turned into the six series colours: hue moved by `dh`, chroma and lightness set +/// to the quiet chart register (low saturation, one lightness step for the whole set). +fn hsl_shift(c: Color32, dh: f32, s: f32, l: f32) -> Color32 { + let (mut h, _, _) = rgb_to_hsl(c); + h = (h + dh).rem_euclid(360.0); + hsl_to_rgb(h, s, l) +} + +fn rgb_to_hsl(c: Color32) -> (f32, f32, f32) { + let (r, g, b) = (c.r() as f32 / 255.0, c.g() as f32 / 255.0, c.b() as f32 / 255.0); + let (mx, mn) = (r.max(g).max(b), r.min(g).min(b)); + let l = (mx + mn) / 2.0; + let d = mx - mn; + if d < 1e-6 { + return (0.0, 0.0, l); + } + let s = d / (1.0 - (2.0 * l - 1.0).abs()); + let h = if mx == r { + 60.0 * (((g - b) / d) % 6.0) + } else if mx == g { + 60.0 * ((b - r) / d + 2.0) + } else { + 60.0 * ((r - g) / d + 4.0) + }; + (h.rem_euclid(360.0), s, l) +} + +fn hsl_to_rgb(h: f32, s: f32, l: f32) -> Color32 { + let c = (1.0 - (2.0 * l - 1.0).abs()) * s; + let x = c * (1.0 - ((h / 60.0) % 2.0 - 1.0).abs()); + let m = l - c / 2.0; + let (r, g, b) = match (h / 60.0).floor() as i32 { + 0 => (c, x, 0.0), + 1 => (x, c, 0.0), + 2 => (0.0, c, x), + 3 => (0.0, x, c), + 4 => (x, 0.0, c), + _ => (c, 0.0, x), + }; + rgb(((r + m) * 255.0).round() as u8, ((g + m) * 255.0).round() as u8, ((b + m) * 255.0).round() as u8) +}