Merge pull request #12 from evanwhittaker/sync-wordmark-and-policy

Animated README wordmark, AI-assistance note and policy
This commit is contained in:
Evan Whittaker
2026-10-17 22:22:28 -05:00
committed by GitHub
15 changed files with 364 additions and 118 deletions

View File

@@ -16,6 +16,20 @@ option. Unless you explicitly state otherwise, any contribution intentionally su
the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
additional terms or conditions.
## AI assistance
AI help is welcome. Luxe is built with plenty of it, much of it Luxe working on itself. Three things
to hold to:
- **Say so.** Name the tool and how much of the change it wrote in the pull request: "written with
Luxe on Claude Sonnet 5.5, then reviewed and edited by me", or "asked ChatGPT how the cache works,
wrote the fix myself". Tab completion doesn't count. A commit can carry the Linux kernel's
`Assisted-by: AGENT:MODEL` trailer.
- **Understand it.** You should be able to explain what your change does and how it fits without
asking the tool. That's the bar for any change, and the one an agent makes easiest to skip.
- **Write to people in your own words.** An issue or a pull request description is read by a person,
so keep it short, and label anything a model wrote.
## The gate
```bash

1
Cargo.lock generated
View File

@@ -1797,6 +1797,7 @@ dependencies = [
"base64",
"crossterm",
"futures",
"gif",
"image",
"luxe-core",
"luxe-tui",

View File

@@ -1,4 +1,9 @@
<h1 align="center"><img src="web/src/assets/generated/wordmark-banner.svg" alt="Luxe" width="420"></h1>
<h1 align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="web/src/assets/generated/wordmark-dark.gif">
<img src="web/src/assets/generated/wordmark-light.gif" alt="Luxe" width="440">
</picture>
</h1>
Luxe is a coding agent for your terminal, written in Rust. It works in your project with the model
you choose, then reads back what it changed as a Guided Review, so you can comment, ask for fixes,
@@ -156,6 +161,10 @@ Every page is also plain markdown in [`docs/guide/`](docs/guide/), and
the site and the demos are made; [`AGENTS.md`](AGENTS.md) has the rules an agent working here holds
to. Problems and questions go to [GitHub issues](https://github.com/evanwhittaker/luxe/issues).
Luxe is built with AI assistance, much of it Luxe working on itself. Every change still passes the
full test suite and CI before it merges, and its maintainer decides what does. If AI helped with
yours, [say so](CONTRIBUTING.md#ai-assistance).
Luxe draws on Pi, by earendil-works, and on OpenCode, and on the unidirectional data flow of Elm
and Ratatui.

View File

@@ -15,6 +15,21 @@ fn project_server(project: &Path) {
std::fs::write(project.join(".mcp.json"), config.to_string()).unwrap();
}
/// Whether Luxe launched the project's server. The marker is the proof when the child gets that far,
/// but the child is this test binary starting up again, and on a slow runner Luxe can give up on the
/// closed connection before that startup reaches the write; its report of the attempt is the proof
/// then. A refused server is never launched, so neither can appear.
fn started(project: &Path, stdout: &str) -> bool {
project.join("mcp-ran").exists() || stdout.contains("project-marker: failed to connect")
}
/// Whether Luxe refused to start the project's server: it says so, naming it. Checked alongside the
/// absent marker, which alone would also pass for a server launched too slowly to have written it.
fn refused(project: &Path, stdout: &str) -> bool {
stdout.contains("Not starting project MCP servers: project-marker")
&& !project.join("mcp-ran").exists()
}
fn tools(project: &Path, home: &Path, trust: bool) -> String {
run_mcp(project, home, trust, "tools")
}
@@ -56,8 +71,8 @@ fn tools_does_not_start_an_untrusted_project_server() {
let home = tempfile::tempdir().unwrap();
project_server(project.path());
let stdout = tools(project.path(), home.path(), false);
assert!(!project.path().join("mcp-ran").exists(), "the project command ran: {stdout}");
assert!(stdout.contains("project-marker") && stdout.contains("--trust-project"), "{stdout}");
assert!(refused(project.path(), &stdout), "the project command ran: {stdout}");
assert!(stdout.contains("--trust-project"), "{stdout}");
}
/// Refusing every project server would silently discard the CLI's explicit trust grant.
@@ -67,7 +82,7 @@ fn tools_starts_a_project_server_with_explicit_trust() {
let home = tempfile::tempdir().unwrap();
project_server(project.path());
let stdout = tools(project.path(), home.path(), true);
assert!(project.path().join("mcp-ran").exists(), "the trusted command never ran: {stdout}");
assert!(started(project.path(), &stdout), "the trusted command never ran: {stdout}");
}
/// CLI tools must honor the same global opt-in the engine uses.
@@ -78,7 +93,7 @@ fn tools_honors_the_user_always_preference() {
project_server(project.path());
tooling_preference(&home.path().join("luxe"), "always");
let stdout = tools(project.path(), home.path(), false);
assert!(project.path().join("mcp-ran").exists(), "the user opt-in was ignored: {stdout}");
assert!(started(project.path(), &stdout), "the user opt-in was ignored: {stdout}");
}
/// Explicit trust must not override the user's global refusal to start project tooling.
@@ -89,7 +104,7 @@ fn tools_honors_the_user_never_preference_even_with_trust() {
project_server(project.path());
tooling_preference(&home.path().join("luxe"), "never");
let stdout = tools(project.path(), home.path(), true);
assert!(!project.path().join("mcp-ran").exists(), "the user refusal was ignored: {stdout}");
assert!(refused(project.path(), &stdout), "the user refusal was ignored: {stdout}");
}
/// A repository must not grant itself permission by setting the global-only tooling preference.
@@ -100,7 +115,7 @@ fn tools_ignores_a_project_always_preference() {
project_server(project.path());
tooling_preference(&project.path().join(".luxe"), "always");
let stdout = tools(project.path(), home.path(), false);
assert!(!project.path().join("mcp-ran").exists(), "the project granted itself trust: {stdout}");
assert!(refused(project.path(), &stdout), "the project granted itself trust: {stdout}");
}
/// The trust filter must not block a server declared by the user, outside the project.
@@ -112,5 +127,5 @@ fn tools_starts_a_user_server_without_project_trust() {
std::fs::create_dir_all(home.path().join("luxe")).unwrap();
std::fs::rename(project.path().join(".mcp.json"), home.path().join("luxe/mcp.json")).unwrap();
let stdout = tools(project.path(), home.path(), false);
assert!(project.path().join("mcp-ran").exists(), "the user command never ran: {stdout}");
assert!(started(project.path(), &stdout), "the user command never ran: {stdout}");
}

View File

@@ -225,7 +225,9 @@ const PATTERNS: [(&str, &str, SecretConfidence, &str); 11] = [
r"AIza[0-9A-Za-z_\-]{35}",
"[REDACTED_GOOGLE_KEY]",
SecretConfidence::Format,
"AIzaabcdefghijklmnopqrstuvwxyz012345678",
// Joined at compile time so the source holds no key-shaped run: a Google key has no
// checksum, so secret scanners flag any literal of its shape, invented ones included
concat!("AIza", "abcdefghijklmnopqrstuvwxyz012345678"),
),
(
r"(?:sk|rk)_(?:live|test)_[0-9A-Za-z]{10,}",

View File

@@ -54,6 +54,8 @@ clipboard-images = ["clipboard"]
# Integration tests link the library without `cfg(test)`; normal dependents keep fixtures off.
luxe-tui = { path = ".", features = ["fixture"] }
tempfile = "3"
# The README's animated wordmark (examples/wordmark_gif). Already in the tree through `image`.
gif = "0.14"
[lints]
workspace = true
@@ -71,6 +73,10 @@ test = true
name = "wordmark_svg"
test = true
[[example]]
name = "wordmark_gif"
test = true
[[example]]
name = "theme_css"
test = true

View File

@@ -0,0 +1,197 @@
//! wordmark_gif — the logotype as the terminal lights it, as a looping GIF for the README.
//!
//! Every frame comes from [`Wordmark::lines_at`], the same rows and the same two lights the
//! dashboard draws, so the recording cannot drift from the product. GitHub shows a README image on
//! its own page background, light or dark, so the background is transparent: the art is hard-edged
//! cells, which GIF's one-bit transparency draws exactly.
//!
//! ```sh
//! cargo run -p luxe-tui --example wordmark_gif -- dark > web/src/assets/generated/wordmark-dark.gif
//! cargo run -p luxe-tui --example wordmark_gif -- light > web/src/assets/generated/wordmark-light.gif
//! ```
use luxe_tui::main_loop::ANIMATION_TICK;
use luxe_tui::widgets::{
Wordmark, WordmarkInk, DRIFT_FRAME_TICKS, DRIFT_PERIOD_TICKS, SHINE_CYCLE_TICKS,
SHINE_SWEEP_TICKS,
};
use ratatui::style::Color;
use std::borrow::Cow;
use std::io::Write;
/// Pixels per cell: the 10×22 grid `wordmark_svg` draws, twice over so the mark stays sharp on a
/// high-density screen when the README shows it at half size.
const CELL_W: usize = 20;
const CELL_H: usize = 44;
fn main() {
let dark = match std::env::args().nth(1).as_deref() {
Some("dark") => true,
Some("light") => false,
other => {
eprintln!("usage: wordmark_gif dark|light (got {other:?})");
std::process::exit(2);
}
};
let mut out = Vec::new();
write_gif(&mut out, ink(dark)).expect("encoding into memory cannot fail");
std::io::stdout().write_all(&out).expect("write the GIF to stdout");
}
/// The luxe theme's accent and canvas. `dark` sets how hard the shine pushes toward white: a light
/// page washes the letters out sooner, so it gets the gentler peak the terminal uses on light
/// themes. The canvas stays the dark one either way, so the drift deepens the brass on both.
fn ink(dark: bool) -> WordmarkInk {
let theme = luxe_core::theme::ThemeRegistry::new().resolve("luxe").expect("a built-in theme");
let rgb = |token: &str| match theme.get(token) {
Some(luxe_core::theme::ColorValue::Rgb(red, green, blue)) => {
Color::Rgb(*red, *green, *blue)
}
other => panic!("the luxe theme's {token} is a color, not {other:?}"),
};
WordmarkInk { accent: rgb("accent"), canvas: Some(rgb("background")), dark }
}
/// The ticks a frame is drawn at across one loop: every tick while the shine crosses, every drift
/// frame while it rests, as the terminal repaints.
///
/// One loop is one drift period, which has to close on itself for the GIF to loop without a seam.
/// The shine crosses once at its start and rests for the remainder.
fn frame_ticks() -> Vec<u64> {
(0..DRIFT_PERIOD_TICKS)
.filter(|&tick| tick < SHINE_SWEEP_TICKS || tick % DRIFT_FRAME_TICKS == 0)
.collect()
}
/// Each frame's delay in hundredths of a second, rounded against the running clock so the loop
/// totals the drift period rather than gaining a rounding error per frame.
fn delays(ticks: &[u64]) -> Vec<u16> {
let tick_ms = ANIMATION_TICK.as_millis() as f64;
let at = |tick: u64| (tick as f64 * tick_ms / 10.0).round() as i64;
let ends = ticks.iter().skip(1).copied().chain([DRIFT_PERIOD_TICKS]);
ticks.iter().zip(ends).map(|(&start, end)| (at(end) - at(start)).max(1) as u16).collect()
}
fn write_gif(out: &mut Vec<u8>, ink: WordmarkInk) -> Result<(), gif::EncodingError> {
let size = Wordmark::Full;
let (width, height) = (usize::from(size.width()) * CELL_W, usize::from(size.height()) * CELL_H);
let mut encoder = gif::Encoder::new(out, width as u16, height as u16, &[])?;
encoder.set_repeat(gif::Repeat::Infinite)?;
let ticks = frame_ticks();
for (&tick, delay) in ticks.iter().zip(delays(&ticks)) {
// The shine's own cycle is shorter than the loop; past it the shine rests
let shine = (tick < SHINE_CYCLE_TICKS).then_some(tick);
let (pixels, palette) = render(size, ink, tick, shine, width);
encoder.write_frame(&frame((width, height), pixels, palette, delay))?;
}
Ok(())
}
/// One whole-canvas frame, index 0 transparent.
fn frame(
(width, height): (usize, usize),
pixels: Vec<u8>,
palette: Vec<u8>,
delay: u16,
) -> gif::Frame<'static> {
gif::Frame {
width: width as u16,
height: height as u16,
buffer: Cow::Owned(pixels),
palette: Some(palette),
transparent: Some(0),
delay,
// Cleared between frames, or a cell turned transparent would keep the last frame's ink
dispose: gif::DisposalMethod::Background,
..gif::Frame::default()
}
}
/// One frame as palette indices and the palette, index 0 transparent.
fn render(
size: Wordmark,
ink: WordmarkInk,
drift: u64,
shine: Option<u64>,
width: usize,
) -> (Vec<u8>, Vec<u8>) {
let mut palette = vec![0u8, 0, 0];
let mut pixels = vec![0u8; width * usize::from(size.height()) * CELL_H];
for (row, line) in size.lines_at(ink, drift, shine).iter().enumerate() {
let cells = line
.spans
.iter()
.flat_map(|span| span.content.chars().map(move |glyph| (glyph, span.style.fg)));
for (column, (glyph, fg)) in cells.enumerate() {
let Some(Color::Rgb(red, green, blue)) = fg else { continue };
let index = palette_index(&mut palette, [red, green, blue]);
ink_cell(&mut pixels, width, (column, row), glyph, index);
}
}
(pixels, palette)
}
/// Paints the part of cell `(column, row)` that `glyph` inks: all of it, or the top or bottom half.
fn ink_cell(
pixels: &mut [u8],
width: usize,
(column, row): (usize, usize),
glyph: char,
index: u8,
) {
let (top, bottom) = match glyph {
'█' => (0, CELL_H),
'▀' => (0, CELL_H / 2),
'▄' => (CELL_H / 2, CELL_H),
_ => return,
};
for y in row * CELL_H + top..row * CELL_H + bottom {
pixels[y * width + column * CELL_W..][..CELL_W].fill(index);
}
}
/// The palette slot for `color`, adding it the first time it is seen.
fn palette_index(palette: &mut Vec<u8>, color: [u8; 3]) -> u8 {
let existing = palette.chunks(3).position(|entry| entry == color);
let index = existing.unwrap_or_else(|| {
palette.extend_from_slice(&color);
palette.len() / 3 - 1
});
u8::try_from(index).expect("a frame of one hue lit two ways stays far under 256 colors")
}
#[cfg(test)]
mod tests {
use super::*;
/// The loop is one drift period to the hundredth of a second, so it closes without a jump.
#[test]
fn the_frames_add_up_to_one_drift_period() {
let total: u32 = delays(&frame_ticks()).iter().map(|&delay| u32::from(delay)).sum();
let period_cs =
(DRIFT_PERIOD_TICKS as f64 * ANIMATION_TICK.as_millis() as f64 / 10.0).round();
assert_eq!(f64::from(total), period_cs);
}
/// The shine crosses frame by frame, and the rest repaints at the drift's slower cadence.
#[test]
fn the_shine_gets_every_tick_and_the_rest_every_drift_frame() {
let ticks = frame_ticks();
assert!((0..SHINE_SWEEP_TICKS).all(|tick| ticks.contains(&tick)));
assert!(ticks
.iter()
.filter(|&&tick| tick >= SHINE_SWEEP_TICKS)
.all(|tick| tick % DRIFT_FRAME_TICKS == 0));
}
/// The background is transparent and the letters are ink: a frame has both.
#[test]
fn a_frame_is_transparent_around_inked_letters() {
let size = Wordmark::Full;
let width = usize::from(size.width()) * CELL_W;
let (pixels, palette) = render(size, ink(true), 0, None, width);
assert!(pixels.contains(&0), "transparent background");
assert!(pixels.iter().any(|&index| index != 0), "inked letters");
assert!(palette.len() / 3 > 1);
}
}

View File

@@ -42,6 +42,11 @@ use std::time::Duration;
use tokio::sync::mpsc;
use tokio::time::interval;
/// The animation tick, about 30 a second: what every timed effect counts in, the wordmark's lights
/// and the spinner included. Public so a recording of one, the README's wordmark, keeps the same
/// time.
pub const ANIMATION_TICK: Duration = Duration::from_millis(33);
/// Why the TUI returned control to the CLI.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum TuiExit {
@@ -181,7 +186,7 @@ pub async fn run(
let mut sources = Sources {
event_rx,
terminal_events: Some(EventStream::new()),
tick: interval(Duration::from_millis(33)), // ~30fps
tick: interval(ANIMATION_TICK),
// One listener for the run, rather than a fresh registration on every pass of a loop that
// turns over as fast as the terminal can deliver keys.
interrupted: Box::pin(tokio::signal::ctrl_c()),

View File

@@ -34,7 +34,8 @@ pub use slab::{
pub use tool_glyph::{tool_glyph, tool_icon, GENERIC_TOOL};
pub use wordmark::{
banner_frame_due, render_wordmark, smoothstep, BannerClock, Wordmark, WordmarkInk, BAND,
DRIFT_DEPTH, LEAN, PEAK_DARK, PEAK_LIGHT, SHINE_CYCLE_TICKS, SHINE_SWEEP_TICKS, STILL_TICK,
DRIFT_DEPTH, DRIFT_FRAME_TICKS, DRIFT_PERIOD_TICKS, LEAN, PEAK_DARK, PEAK_LIGHT,
SHINE_CYCLE_TICKS, SHINE_SWEEP_TICKS, STILL_TICK,
};
pub use wrap::{wrap_cells, wrap_line, wrap_lines, wrapped_row_starts};

View File

@@ -23,8 +23,11 @@
//! wordmark in the flat accent and skip both rather than approximate them.
mod art;
mod light;
use art::{column_groups, FULL_ART, LINE_ART, SMALL_ART};
pub use light::smoothstep;
use light::{blend_toward, Pass};
use ratatui::layout::{Alignment, Rect};
use ratatui::style::{Color, Modifier, Style};
use ratatui::text::{Line, Span};
@@ -194,14 +197,23 @@ impl Wordmark {
/// A still is a frame of the same animation rather than a separate code path, so what a reader
/// sees with `banner_animation = false` is a moment of what everyone else sees moving.
pub fn lines(self, ink: WordmarkInk, tick: Option<u64>) -> Vec<Line<'static>> {
let (tick, pass) = match tick {
Some(tick) => (tick, Pass::at(self, ink, tick)),
None => (STILL_TICK, None),
};
match tick {
Some(tick) => self.lines_at(ink, tick, Some(tick)),
None => self.lines_at(ink, STILL_TICK, None),
}
}
/// The logotype's rows with each light set on its own: the drift at `drift`, and the shine at
/// `shine`, or none when that is `None`.
///
/// The terminal runs both from one clock and keeps them out of step on purpose, so its pattern
/// takes minutes to repeat. A recording has to loop, so it sets the two to meet.
pub fn lines_at(self, ink: WordmarkInk, drift: u64, shine: Option<u64>) -> Vec<Line<'static>> {
let pass = shine.and_then(|tick| Pass::at(self, ink, tick));
self.rows()
.iter()
.enumerate()
.map(|(row, text)| self.row_line(text, row as u16, ink, tick, pass.as_ref()))
.map(|(row, text)| self.row_line(text, row as u16, ink, drift, pass.as_ref()))
.collect()
}
@@ -412,78 +424,13 @@ pub fn render_wordmark(
pub const SHINE_SWEEP_TICKS: u64 = SWEEP_TICKS;
/// One pass plus its rest, in ticks.
pub const SHINE_CYCLE_TICKS: u64 = CYCLE_TICKS;
/// One whole pass of the drift, in ticks.
pub const DRIFT_PERIOD_TICKS: u64 = DRIFT_TICKS;
/// Ticks between drift frames while no shine runs.
pub const DRIFT_FRAME_TICKS: u64 = DRIFT_FRAME;
fn shine_active(tick: u64) -> bool {
tick % CYCLE_TICKS < SWEEP_TICKS
}
/// One tick of one pass: where the highlight band sits, and how hard it pushes.
struct Pass {
center: f32,
half: f32,
peak: f32,
lean: f32,
}
impl Pass {
/// The pass in flight at `tick`, or `None` while the logotype rests.
fn at(size: Wordmark, ink: WordmarkInk, tick: u64) -> Option<Self> {
let phase = tick % CYCLE_TICKS;
if phase >= SWEEP_TICKS {
return None;
}
let span = size.span();
let half = (span * BAND).max(1.0);
let travel = span + 2.0 * half;
let progress = phase as f32 / SWEEP_TICKS as f32;
Some(Self {
// The band starts and ends clear of the letters, so a pass arrives and leaves rather
// than appearing half-drawn across them.
center: -half + progress * travel,
half,
peak: if ink.dark { PEAK_DARK } else { PEAK_LIGHT },
lean: LEAN,
})
}
/// How far this cell is lifted toward the highlight.
fn lift(&self, column: u16, row: u16) -> f32 {
let axis = f32::from(column) + self.lean * f32::from(row);
let distance = ((axis - self.center).abs() / self.half).min(1.0);
smoothstep(1.0 - distance) * self.peak
}
}
/// Smooth 0→1 with zero slope at both ends, so a band edge has no seam.
///
/// The shape of the highlight, and the whole reason it reads as light rather than as a stripe: a
/// linear falloff leaves a crease along the ridge and a hard shoulder at each edge. Public so the
/// website samples this curve rather than approximating it.
pub fn smoothstep(t: f32) -> f32 {
let t = t.clamp(0.0, 1.0);
t * t * (3.0 - 2.0 * t)
}
/// Alpha-blend `base` `amount` of the way toward `target`.
///
/// An ANSI/indexed palette has no channels to mix, so an unblendable color comes back untouched
/// rather than as an invented RGB approximation of the terminal's own.
fn blend_toward(base: Color, target: Color, amount: f32) -> Color {
let (Color::Rgb(red, green, blue), Color::Rgb(tr, tg, tb)) = (base, target) else {
return base;
};
if amount <= 0.0 {
return base;
}
let amount = amount.clamp(0.0, 1.0);
let lift = |channel: u8, toward: u8| {
(f32::from(channel) + (f32::from(toward) - f32::from(channel)) * amount)
.round()
.clamp(0.0, 255.0) as u8
};
Color::Rgb(lift(red, tr), lift(green, tg), lift(blue, tb))
}
#[cfg(test)]
mod tests;

View File

@@ -0,0 +1,75 @@
//! Light — the shine's band, the curve it falls off along, and the blend both lights paint with.
//!
//! The math of the two lights on their own, apart from the art they land on: the parent decides
//! which cells are ink and asks here how far each one is lifted.
use super::{Wordmark, WordmarkInk, BAND, CYCLE_TICKS, LEAN, PEAK_DARK, PEAK_LIGHT, SWEEP_TICKS};
use ratatui::style::Color;
/// One tick of one pass: where the highlight band sits, and how hard it pushes.
pub(super) struct Pass {
center: f32,
half: f32,
peak: f32,
lean: f32,
}
impl Pass {
/// The pass in flight at `tick`, or `None` while the logotype rests.
pub(super) fn at(size: Wordmark, ink: WordmarkInk, tick: u64) -> Option<Self> {
let phase = tick % CYCLE_TICKS;
if phase >= SWEEP_TICKS {
return None;
}
let span = size.span();
let half = (span * BAND).max(1.0);
let travel = span + 2.0 * half;
let progress = phase as f32 / SWEEP_TICKS as f32;
Some(Self {
// The band starts and ends clear of the letters, so a pass arrives and leaves rather
// than appearing half-drawn across them.
center: -half + progress * travel,
half,
peak: if ink.dark { PEAK_DARK } else { PEAK_LIGHT },
lean: LEAN,
})
}
/// How far this cell is lifted toward the highlight.
pub(super) fn lift(&self, column: u16, row: u16) -> f32 {
let axis = f32::from(column) + self.lean * f32::from(row);
let distance = ((axis - self.center).abs() / self.half).min(1.0);
smoothstep(1.0 - distance) * self.peak
}
}
/// Smooth 0→1 with zero slope at both ends, so a band edge has no seam.
///
/// The shape of the highlight, and the whole reason it reads as light rather than as a stripe: a
/// linear falloff leaves a crease along the ridge and a hard shoulder at each edge. Public so the
/// website samples this curve rather than approximating it.
pub fn smoothstep(t: f32) -> f32 {
let t = t.clamp(0.0, 1.0);
t * t * (3.0 - 2.0 * t)
}
/// Alpha-blend `base` `amount` of the way toward `target`.
///
/// An ANSI/indexed palette has no channels to mix, so an unblendable color comes back untouched
/// rather than as an invented RGB approximation of the terminal's own.
pub(super) fn blend_toward(base: Color, target: Color, amount: f32) -> Color {
let (Color::Rgb(red, green, blue), Color::Rgb(tr, tg, tb)) = (base, target) else {
return base;
};
if amount <= 0.0 {
return base;
}
let amount = amount.clamp(0.0, 1.0);
let lift = |channel: u8, toward: u8| {
(f32::from(channel) + (f32::from(toward) - f32::from(channel)) * amount)
.round()
.clamp(0.0, 255.0) as u8
};
Color::Rgb(lift(red, tr), lift(green, tg), lift(blue, tb))
}

View File

@@ -140,28 +140,9 @@ wordmark() { cargo run --quiet --release -p luxe-tui --example wordmark_svg -- "
tokens() { cargo run --quiet --release -p luxe-tui --example theme_css; }
catalog() { cargo run --quiet --release -p luxe-tui --example theme_css -- --json; }
shiki() { cargo run --quiet --release -p luxe-tui --example shiki_theme -- "$@"; }
# The README's wordmark. GitHub shows an image on its own, where the CSS variables the site paints
# the letters with do not exist and every letter would fall back to black, so this copy carries
# the theme's own colors and its background: the same on GitHub's light pages as on its dark ones.
banner() {
python3 - "$1/wordmark.svg" "$1/tokens.css" <<'PY'
import re, sys
svg, css = (open(path).read() for path in sys.argv[1:])
color = lambda name: re.search(rf"--luxe-{name}:\s*(#[0-9a-f]{{6}})", css).group(1)
svg = re.sub(r"var\(--luxe-(wordmark-\d), currentColor\)", lambda m: color(m.group(1)), svg)
width, height = (int(n) for n in re.search(r'viewBox="0 0 (\d+) (\d+)"', svg).groups())
pad_x, pad_y = 120, 72
box = (width + 2 * pad_x, height + 2 * pad_y)
svg = re.sub(
r'viewBox="[^"]*" width="\d+" height="\d+"',
f'viewBox="{-pad_x} {-pad_y} {box[0]} {box[1]}" width="{box[0]}" height="{box[1]}"',
svg,
)
background = f'<rect x="{-pad_x}" y="{-pad_y}" width="{box[0]}" height="{box[1]}" rx="16" fill="{color("background")}"/>'
print(svg.replace("</title>", "</title>\n " + background, 1), end="")
PY
}
# The README's wordmark, animated as the terminal lights it, transparent for GitHub's light and dark
# pages alike. Two variants: a light page washes the shine out sooner, so it gets the gentler one
wordmark_gif() { cargo run --quiet --release -p luxe-tui --example wordmark_gif -- "$@"; }
generate() {
local target="$1" guide_target="$2"
@@ -171,7 +152,8 @@ generate() {
wordmark mark >"${target}/mark.svg"
wordmark tile >"${target}/tile.svg"
tokens >"${target}/tokens.css"
banner "${target}" >"${target}/wordmark-banner.svg"
wordmark_gif dark >"${target}/wordmark-dark.gif"
wordmark_gif light >"${target}/wordmark-light.gif"
catalog >"${target}/themes.json"
facts "${target}" >"${target}/facts.json"
shiki luxe >"${target}/shiki-luxe.json"
@@ -211,7 +193,8 @@ print(','.join(['luxe'] + names))
# One release build up front. Every generator is a separate `cargo run`, and letting each discover
# that for itself turns a five-second job into a minute of cargo deciding it has nothing to do.
cargo build --quiet --release -p luxe-tui --features fixture \
--example fixture_svg --example wordmark_svg --example theme_css --example shiki_theme
--example fixture_svg --example wordmark_svg --example wordmark_gif --example theme_css \
--example shiki_theme
if [[ "${check}" == true ]]; then
scratch="$(mktemp -d)"

View File

@@ -1,9 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-120 -72 680 298" width="680" height="298" data-cell="10 22" role="img" aria-label="Luxe">
<title>Luxe</title>
<rect x="-120" y="-72" width="680" height="298" rx="16" fill="#12100e"/>
<path fill="#6d5f43" d="M10 11h10v11h-10z M20 11h10v11h-10z M30 11h10v11h-10z M40 11h10v11h-10z M10 22h10v11h-10z M20 22h10v11h-10z M30 22h20v22h-20z M30 44h20v22h-20z M30 66h20v22h-20z M30 88h20v22h-20z M30 110h20v22h-20z M50 121h10v11h-10z M60 121h10v11h-10z M70 121h10v11h-10z M40 132h10v11h-10z M50 132h10v11h-10z M60 132h10v11h-10z M70 132h10v11h-10z"/>
<path fill="#7e6d4d" d="M110 44h20v22h-20z M170 44h20v22h-20z M110 66h20v22h-20z M170 66h20v22h-20z M110 88h20v22h-20z M170 88h20v22h-20z M110 110h20v22h-20z M130 121h10v11h-10z M140 121h10v11h-10z M150 121h10v11h-10z M160 110h30v22h-30z M120 132h10v11h-10z M130 132h10v11h-10z M140 132h10v11h-10z M150 132h10v11h-10z M170 132h10v11h-10z M180 132h10v11h-10z"/>
<path fill="#a59064" d="M210 44h10v11h-10z M220 44h20v22h-20z M260 44h20v22h-20z M280 44h10v11h-10z M230 66h40v22h-40z M230 99h10v11h-10z M240 88h20v22h-20z M260 99h10v11h-10z M220 121h10v11h-10z M230 110h10v22h-10z M240 110h10v11h-10z M250 110h10v11h-10z M260 110h10v22h-10z M270 121h10v11h-10z M210 132h10v11h-10z M220 132h10v11h-10z M230 132h10v11h-10z M260 132h10v11h-10z M270 132h10v11h-10z M280 132h10v11h-10z"/>
<path fill="#cdb27a" d="M320 55h10v11h-10z M330 44h40v22h-40z M370 55h10v11h-10z M310 66h20v22h-20z M330 77h10v11h-10z M340 77h10v11h-10z M350 77h10v11h-10z M360 77h10v11h-10z M370 66h20v22h-20z M310 88h20v22h-20z M330 88h10v11h-10z M340 88h10v11h-10z M350 88h10v11h-10z M360 88h10v11h-10z M370 88h10v11h-10z M380 88h10v11h-10z M310 110h10v11h-10z M320 110h20v22h-20z M340 121h10v11h-10z M350 121h10v11h-10z M360 121h10v11h-10z M370 121h10v11h-10z M380 110h10v22h-10z M330 132h10v11h-10z M340 132h10v11h-10z M350 132h10v11h-10z M360 132h10v11h-10z M370 132h10v11h-10z"/>
<path fill="#ddc084" d="M420 110h20v22h-20z M420 132h10v11h-10z M430 132h10v11h-10z"/>
</svg>

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 KiB