The blue, green, red scale's lightness rose and then fell (L* 44 up to 72 and back to 50), so a flat face and a tight radius looked alike with hue lost, and its upper part merged for a red-green loss. The stops are now dark blue, a middle grey-gold and light yellow in one straight blend, as measured in the issue: L* rises the whole way and every quarter step stays clear for normal, protan, deutan and tritan vision. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -271,8 +271,16 @@ fn pictures_show_the_surface_analysis() {
|
||||
let plain = picture(&s);
|
||||
s.execute("inspect.curvature_map", &json!({})).unwrap();
|
||||
let curvature = picture(&s);
|
||||
let blue = |img: &[u8]| pixels(img).filter(|p| i32::from(p[2]) - i32::from(p[0]) > 120 && p[1] < 140).count();
|
||||
assert!(blue(&curvature) > 3000 && blue(&plain) == 0, "flat faces in the flat colour: {} (plain {})", blue(&curvature), blue(&plain));
|
||||
let near = |p: [u8; 4], c: [u8; 3]| (0..3).all(|k| (i32::from(p[k]) - i32::from(c[k])).abs() < 60);
|
||||
let flat = solidcraft_engine::render::AnalysisColors::DEFAULT.curvature[0].map(|v| (v * 255.0).round() as u8);
|
||||
let flats = |img: &[u8]| pixels(img).filter(|p| near(*p, flat)).count();
|
||||
// The flat colour is dark, so the plain picture's edge lines come near it in places.
|
||||
assert!(
|
||||
flats(&curvature) > 3000 && flats(&plain) * 10 < flats(&curvature),
|
||||
"flat faces in the flat colour: {} (plain {})",
|
||||
flats(&curvature),
|
||||
flats(&plain)
|
||||
);
|
||||
s.execute("inspect.zebra", &json!({})).unwrap();
|
||||
let zebra = picture(&s);
|
||||
let black = pixels(&zebra).filter(|p| p[0] < 40 && p[1] < 40 && p[2] < 40).count();
|
||||
@@ -281,7 +289,6 @@ fn pictures_show_the_surface_analysis() {
|
||||
s.execute("inspect.accessibility", &json!({})).unwrap();
|
||||
let access = picture(&s);
|
||||
let [ok, blocked] = colors_of(solidcraft_engine::render::AnalysisColors::DEFAULT.access);
|
||||
let near = |p: [u8; 4], c: [u8; 3]| (0..3).all(|k| (i32::from(p[k]) - i32::from(c[k])).abs() < 60);
|
||||
let (reachable, under) = (pixels(&access).filter(|p| near(*p, ok)).count(), pixels(&access).filter(|p| near(*p, blocked)).count());
|
||||
assert!(reachable > 1000 && under > 1000, "accessibility: {reachable} reachable, {under} blocked pixels");
|
||||
}
|
||||
|
||||
@@ -9,7 +9,9 @@ pub struct AnalysisColors {
|
||||
pub draft: [[f32; 3]; 3],
|
||||
/// Accessibility Analysis: reachable, blocked.
|
||||
pub access: [[f32; 3]; 2],
|
||||
/// Curvature Map: flat, the middle of the scale, at or below the analysis radius.
|
||||
/// Curvature Map: flat, the middle of the scale, at or below the analysis radius. Dark blue
|
||||
/// to light yellow in one straight blend, so the lightness rises the whole way and the scale
|
||||
/// reads with hue lost too (#975).
|
||||
pub curvature: [[f32; 3]; 3],
|
||||
/// Stripe the negative draft and blocked faces too, so colour is not the only cue.
|
||||
pub hatch: bool,
|
||||
@@ -20,7 +22,7 @@ impl AnalysisColors {
|
||||
pub const DEFAULT: AnalysisColors = AnalysisColors {
|
||||
draft: [[0.20, 0.75, 0.30], [0.95, 0.80, 0.15], [0.85, 0.22, 0.20]],
|
||||
access: [[0.20, 0.75, 0.30], [0.85, 0.22, 0.20]],
|
||||
curvature: [[0.15, 0.35, 0.95], [0.10, 0.80, 0.25], [0.90, 0.15, 0.10]],
|
||||
curvature: [[0.08, 0.12, 0.45], [0.53, 0.51, 0.425], [0.98, 0.90, 0.40]],
|
||||
hatch: false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ fn moved_colours_keep_the_values_they_were_drawn_with() {
|
||||
// The shader's former literals, bit for bit.
|
||||
assert_eq!(t.analysis.draft, [[0.20, 0.75, 0.30], [0.95, 0.80, 0.15], [0.85, 0.22, 0.20]]);
|
||||
assert_eq!(t.analysis.access, [[0.20, 0.75, 0.30], [0.85, 0.22, 0.20]]);
|
||||
assert_eq!(t.analysis.curvature, [[0.15, 0.35, 0.95], [0.10, 0.80, 0.25], [0.90, 0.15, 0.10]]);
|
||||
assert_eq!(t.analysis.curvature, [[0.08, 0.12, 0.45], [0.53, 0.51, 0.425], [0.98, 0.90, 0.40]]);
|
||||
assert!(!t.analysis.hatch);
|
||||
assert_eq!(t.logo, [Color32::from_rgb(96, 158, 236), Color32::from_rgb(58, 136, 238), Color32::from_rgb(55, 108, 197)]);
|
||||
assert_eq!(t.icons.marker_halo, Color32::from_black_alpha(150));
|
||||
|
||||
@@ -318,9 +318,8 @@ fn groups(t: &Tokens) -> Vec<Group> {
|
||||
],
|
||||
&[("body", t.body), ("viewport_top", t.viewport_top)],
|
||||
),
|
||||
// The scale's three stops, unlit. Shaded (a stop at one angle to the light, the next at
|
||||
// another), middle and tight merge for a red-green loss (3.3 protan, 5.2 deutan) and flat
|
||||
// and middle for tritan (4.6). That is the scale's own fault, in Off too: #975.
|
||||
// The scale's three stops, unlit. Along the scale, see
|
||||
// `the_curvature_scale_lightens_steadily_for_every_eye` (#975).
|
||||
group(
|
||||
"curvature map",
|
||||
&[
|
||||
@@ -1043,3 +1042,24 @@ fn cancel_puts_the_mode_back_ok_keeps_it_and_restore_defaults_resets_interface_o
|
||||
assert_eq!(app.preferences.color_vision, ColorVision::Off);
|
||||
control(&mut app, json!({"button": "ok"}));
|
||||
}
|
||||
|
||||
/// #975: the Curvature Map reads from flat to tight with hue lost too. Along the shader's two
|
||||
/// blends its lightness rises the whole way, and each quarter of the scale is a clear step, for
|
||||
/// normal vision and each simulated loss. The former blue, green, red scale rose and fell.
|
||||
#[test]
|
||||
fn the_curvature_scale_lightens_steadily_for_every_eye() {
|
||||
let c = Tokens::light().analysis.curvature;
|
||||
// Flat to middle over the first half, middle to tight over the second, as the shader mixes.
|
||||
let at = |t: f64| -> Rgb8 {
|
||||
let (a, b, u) = if t < 0.5 { (c[0], c[1], t * 2.0) } else { (c[1], c[2], t * 2.0 - 1.0) };
|
||||
std::array::from_fn(|k| ((f64::from(a[k]) + (f64::from(b[k]) - f64::from(a[k])) * u) * 255.0).round().clamp(0.0, 255.0) as u8)
|
||||
};
|
||||
for eye in [Eye::Normal, Eye::Protan, Eye::Deutan, Eye::Tritan] {
|
||||
let labs: Vec<V3> = (0..=4).map(|i| lab(simulate(at(f64::from(i) / 4.0), eye, Instrument::Machado))).collect();
|
||||
for w in labs.windows(2) {
|
||||
assert!(w[1][0] > w[0][0], "{eye:?}: the lightness falls along the scale: {labs:?}");
|
||||
let step = de2000(w[0], w[1]);
|
||||
assert!(step >= 10.0, "{eye:?}: a quarter of the scale is only {step:.1} apart: {labs:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user