docs(design)+test(palette-extract): r2 三条口径修正与常数绑定
- LowChroma 文档:删掉「彩度必然 < 候选门槛 5」(人气门槛也会淘汰高彩度小面积, 实测 0.5% 纯红报 113.36),改为与契约文档 §6 一致的口径;代码臂注释与 score::most_chromatic 同步 - Seed::color / share 改成有边界的说法:≤MAX_SAMPLES 才是图上真实色、share 的分母是有效采样点 - palette-extract 新增 max_edge_stays_within_the_design_sample_budget: MAX_EDGE² ≤ MAX_SAMPLES(256² 当前余量为零,调大就红) - card.rs:把 6.43~6.50 / 7.70~7.76 写成断言(原来只有 ≥4.5 下限,文档却宣称区间) - LowChroma.color 字段注释改成「最接近可用的候选色」(113 那条并不「能用」)
This commit is contained in:
1 parent
f4c48752c2
commit
09b716ae79
4 files changed
+69
-16
No files matched your search
@@ -156,6 +156,21 @@ fn absurd_dimensions_are_rejected_before_allocating() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn max_edge_stays_within_the_design_sample_budget() {
|
||||
// 结构性防线(复审 r2 要求):`unlucky_design` 只在「像素数 ≤ MAX_SAMPLES」时才不做块平均,
|
||||
// 也只有那时 `Seed::color` 才保证是图上真实存在的颜色。当前 256² = 65536 = MAX_SAMPLES,
|
||||
// **余量为零**——谁把 MAX_EDGE 调到 512,UI 路径就会开始返回「块平均出来的、图上不存在的
|
||||
// 颜色」(例如红蓝交替被平均成 #703C75),而没有任何东西会红。这条把两个常数绑在一起。
|
||||
let budget = unlucky_design::palette::MAX_SAMPLES;
|
||||
let edge = MAX_EDGE as usize;
|
||||
assert!(
|
||||
edge * edge <= budget,
|
||||
"MAX_EDGE={MAX_EDGE} 的平方({})超过 design 的采样预算 {budget}: 调大它之前先读 `unlucky_design::palette::Seed::color` 的文档——超过预算后种子不再是图上真实存在的颜色",
|
||||
edge * edge
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn input_borrows_without_copying() {
|
||||
let loaded = decode_bytes(&encode_png(&solid_image(4, 4, [0x67, 0x50, 0xA4])));
|
||||
|
||||
Reference in new issue
Block a user