Color Wheel: the contrast fix test checks that the fix is the closest gray

The test of the #777777 fix now also checks that the gray one 8-bit step
lighter than the fix fails AA, so a search that lands on a darker gray
fails it. The doc comment of `contrast_lines` names its `narrow`
parameter, and `docs/mcp.md` says that Enter applies the focused fix
chip, as a click does.
This commit is contained in:
dotCooCoo committed 2026-11-21 02:21:45 -08:00
1 parent 6be0bafa72
commit 463bdbcac7
3 files changed
+5 -2

No files matched your search

+3
View File
@@ -899,6 +899,9 @@ fn a_fix_passes_as_the_canvas_paints_it() {
let painted = fix.to_rgb_uncalibrated().map(|v| (v.clamp(0.0, 1.0) * 255.0).round() / 255.0);
let got = vectorcraft_color::wcag::contrast_ratio(painted, [1.0; 3]);
assert!(got >= 4.5, "{fix:?} paints as {painted:?}: {got}");
// The fix is the closest one: the gray one 8-bit step lighter fails.
let lighter = painted.map(|v| (v + 1.0 / 255.0).min(1.0));
assert!(vectorcraft_color::wcag::contrast_ratio(lighter, [1.0; 3]) < 4.5, "{fix:?} paints as {painted:?}");
let back = s.execute("color.contrast", &json!({"color": r["fix"]["aa"], "against": "#ffffff"})).unwrap();
assert!((4.5..4.57).contains(&ratio(&back)), "{back}");
}
+1 -1
View File
@@ -816,7 +816,7 @@ type Bands = Vec<(f32, FieldPoint, FieldPoint)>;
/// field coordinates. The field is sampled on a grid of `n` + 1 columns and rows, and each cell
/// whose corners fall on both sides gets a segment between the crossings on its edges, placed by
/// bisection (marching squares; a cell with two opposite corners passing is split by its center).
/// With `bands`, around a failing sample higher than its neighbors in a column or a row, the highest
/// With `narrow`, around a failing sample higher than its neighbors in a column or a row, the highest
/// ratio is looked for, so a passing band narrower than the samples gets its two edges too, joined
/// from column to column or from row to row. Segments that share an end are joined into one
/// polyline.
+1 -1
View File
@@ -698,7 +698,7 @@ box, `contrastFor` (`normalText`, `largeText` or `graphics`, which has AA only)
`contrastBackground` (a color, or `null` for the color behind the selection) pins the background it measures against,
as `color.contrast` below answers it. With the row shown, the wheel's square and the box's field draw lines where the
color picked there meets AA (solid) and AAA (dashed) for the category, and when the color fails a level, a chip at the
end of the row shows `color.contrast`'s `fix` for the first level it fails; a click applies it.
end of the row shows `color.contrast`'s `fix` for the first level it fails; a click, or Enter while the chip has the focus, applies it.
`{"documentColors": true}` shows the row the panel menu's Show Document Colors adds
under the wheel or the box. The command returns `{view, channel, sliders, gamut, harmony, harmonyRule, contrast, contrastFor,
contrastBackground, vision, documentColors}`, and the settings are kept with the preferences.