Files
pxpipe/src/rust/examples/diff_render.rs
T
teamchong f20207cd7b Rename: claude-image-proxy -> pixelpipe (Tier 1: code + docs)
Project rename for the Show HN launch with framing:
  'pixelpipe — what if Opus saw a UI instead of just append-only logs?'

Renamed everywhere:
  - kebab-case 'claude-image-proxy' -> 'pixelpipe' (42 occurrences)
  - snake_case 'claude_image_proxy' -> 'pixelpipe'  (5 occurrences)
  - 14 files touched: package.json, Cargo.toml, Cargo.lock, *.md,
    bin/cli.js, scripts/install.js, src/proxy.py, src/rust/src/main.rs,
    src/rust/examples/{render_sample,transform_only,diff_render}.rs,
    src/zig/build.zig

Effects on build artifacts:
  - npm package name -> 'pixelpipe'
  - Rust binary name -> target/release/pixelpipe (was claude-image-proxy)
  - Python cache dir -> ~/.cache/pixelpipe/ (was ~/.cache/claude-image-proxy/)

NOT YET DONE in this commit (Tier 2+3, handled in next commit):
  - Repo on-disk directory still ~/Downloads/repos/claude-image-proxy/
  - Cache dir on disk still ~/.cache/claude-image-proxy/ — Python proxy
    currently writes here. Will be migrated alongside the running services
    in a coordinated stop/move/restart sequence.

Validation: scripts/diff_transform.py still produces exactly 1 structural
diff (the PNG bytes, expected — different fonts Python/Menlo vs
Rust/JetBrains Mono). No regression from the rename.
2026-05-18 14:16:48 -04:00

49 lines
1.6 KiB
Rust

//! Diff harness companion: read a JSON spec {name: text, ...}, render each via
//! the Rust pipeline, write PNGs to <out_dir>/<name>_<idx>.png, then emit
//! <out_dir>/manifest.json mapping name -> [filenames].
//!
//! Run: cargo run --release --example diff_render -- <spec.json> <out_dir>
use std::collections::BTreeMap;
use std::path::PathBuf;
use pixelpipe::font::AtlasFont;
use pixelpipe::render::render_chunks;
fn main() -> anyhow::Result<()> {
let mut args = std::env::args().skip(1);
let spec_path: PathBuf = args
.next()
.ok_or_else(|| anyhow::anyhow!("usage: diff_render <spec.json> <out_dir>"))?
.into();
let out_dir: PathBuf = args
.next()
.ok_or_else(|| anyhow::anyhow!("usage: diff_render <spec.json> <out_dir>"))?
.into();
let spec_bytes = std::fs::read(&spec_path)?;
let spec: BTreeMap<String, String> = serde_json::from_slice(&spec_bytes)?;
let font = AtlasFont::load(5.0)?;
let mut manifest: BTreeMap<String, Vec<String>> = BTreeMap::new();
for (name, text) in &spec {
let pngs = render_chunks(&font, text);
let mut filenames = Vec::with_capacity(pngs.len());
for (i, png) in pngs.iter().enumerate() {
let fname = format!("{name}_{i}.png");
std::fs::write(out_dir.join(&fname), &png.bytes)?;
filenames.push(fname);
}
manifest.insert(name.clone(), filenames);
}
std::fs::write(
out_dir.join("manifest.json"),
serde_json::to_vec_pretty(&manifest)?,
)?;
eprintln!("rendered {} samples", spec.len());
Ok(())
}