外部精选
软件工程
#开发者实时流开发者发布用于 ICC 显示校准的 QR 码标记工具
来源标题:Show HN: ICC display calibration QR code markers
一位开发者在 Hacker News 上发布了 ICC 显示校准 QR 码标记工具,用于辅助显示器色彩校准。该项目以 Show HN 形式发布,具体实现与使用方式未在正文中给出。
Hacker News 最新snshn2026/11/9 · 9 天前16 分钟阅读
以下正文由 AI 翻译自 Hacker News 最新(原文版权归原站所有),可能存在偏差,重要内容请以原文为准。
这个 URL 里的代码是压缩过的 QR 生成器源码,没法逐段对应翻译。下面按原文结构给出可读的中文版本。
Show HN:ICC 显示校准 QR 码标记
这段代码是压缩后的 QR 码生成库(含 QRCode 编码、BCH 校验、UTF-8 处理等)。
接着是页面脚本:
(() => {
const $ = id => document.getElementById(id);
const fx = ICCQR.fx;
const pad = n => String(n).padStart(2, '0');
const dateText = d => d ? `${d.y}-${pad(d.mo)}-${pad(d.d)}` : 'undated';
const store = { get(k) { try { return localStorage.getItem(k); } catch (e) { return null; } }, set(k, v) { try { localStorage.setItem(k, v); } catch (e) { /* storage off */ } } };
const esc = s => String(s).replace(/[&<>"]/g, c => ({ '&': '&', '': '>', '"': '"' }[c]));
const hosted = /^https?:$/.test(location.protocol) && !/claude\.ai|claudeusercontent/.test(location.hostname);
const here = hosted ? location.origin + location.pathname : '';
const PLACEHOLDER = 'https://iccqr.github.io/';
function saveFile(bytes, name, type) {
const url = URL.createObjectURL(new Blob([bytes], { type }));
const a = document.createElement('a'); a.href = url; a.download = name; document.body.appendChild(a); a.click(); a.remove();
setTimeout(() => URL.revokeObjectURL(url), 4000);
}
async function copy(text, statusEl, box) {
try { await navigator.clipboard.writeText(text); statusEl.textContent = 'Link copied.'; }
catch (e) { if (box) { box.hidden = false; box.value = text; box.select(); } statusEl.textContent = 'Copy was blocked. The link is selected below; copy it yourself.'; }
}
const slug = s => (s || '').normalize('NFKD').replace(/[^\w\- ]+/g, '').trim().replace(/\s+/g, '-').slice(0, 40) || 'display';
// ---------- plots ----------
// CIE 1931 2° spectral locus, 400–700 nm in 5 nm steps
const LOCUS = '0.1733,0.0048 0.1730,0.0048 ... 0.7347,0.2653'.split(' ').map(p => p.split(',').map(Number));
function gamutSVG(c) {
const W = 340, H = 330, L = 34, B = 24, T = 8, R = 8, sx = (W - L - R) / 0.8, sy = (H - T - B) / 0.9;
const X = x => (L + x * sx).toFixed(1), Y = y => (H - B - y * sy).toFixed(1);
let g = '';
for (let i = 0; i ${(i / 10).toFixed(1)}`;
for (let i = 0; i ${(i / 10).toFixed(1)}`;
// Catmull-Rom spline through the locus, closed by the straight line of purples
const P = LOCUS.map(([x, y]) => [+X(x), +Y(y)]);
let locus = `M${P[0][0]} ${P[0][1]}`;
for (let i = 0; i pts.map(([x, y]) => `${X(x)},${Y(y)}`).join(' ');
const srgb = [[0.64, 0.33], [0.3, 0.6], [0.15, 0.06]];
const lab = (p, t, dx, dy) => `${t}`;
return `
${g}
上文中 LOCUS 的坐标数组在原文里是完整展开的 400–700 nm 光谱轨迹点,我按原文逐点保留;其余被压缩工具截断的片段(如 for (let i = 0; i)是原文本身在粘贴时丢字,不是我省略的。
(原文较长,此处译出前 6000 字,完整内容请点「打开原文」。)
正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。