This PR introduces a new unit test salience::salience_sort(). You can run it with cargo test --test salience saliece_sort -- --show-output.
This unit test will generate a set of standardized or random colors to sort with. You will be able to adjust how salience puts weight on the Jmh components for calculation purposes. We are interested on these lines of code.
fn salience_sort(){// IMPORTANT: Adjust the component weights to figure out what seem best.
//
// Mess around with a color picker here to get a feel on how these
// components work: https://apps.colorjs.io/picker/cam16-jmh
//
// j: lightness
// m: colorfulness
// h: hue
letcustom_weights: WeightsType=[1.0,1.0,1.0];// IMPORTANT: Set this to whatever your background terminal is.
letbg="#010605";// Here we generate the colors. See GenRange.
letj=GenRange::new(10.0,100.0,0.25);letm=GenRange::new(0.0,100.0,0.25);leth=GenRange::new(0.0,180.0,0.25);let(mutcols,view)=setup_cols(ColorOrder::LightFirst,j,m,h);letrgb_bg: Srgb<u8>=bg.parse().unwrap();letcam16=Cam16::from_xyz(rgb_bg.into_linear().into_color(),view);letbg=Spec::from_color(cam16);// // Or alternatively, use the naive variant. Make sure you change the
// // sort to naive as well
// let bg = DARKEST_COL;
// // See what initial colors we're working with
// print_visual(&cols, view);
// println!("============================================");
// let w = Weights::Salience.value();
letw=custom_weights;// // Uncomment me if you're using naive sorting
// let ord: ColorOrder = ColorOrder::LightFirst;
// cols.sort_by(|a, b| a.sal_naive(&ord, false, w).partial_cmp(&b.sal_naive(&ord, false, w)).unwrap_or(Ordering::Equal));
cols.sort_by(|a,b|a.sal(&bg,false,w).partial_cmp(&b.sal(&bg,false,w)).unwrap_or(Ordering::Equal));print_visual(&cols,view);}Please adjust the weights, run the test, and re-adjust weights until you find the "correct" weights were sorting looks the best to you. As a reminder, the objective of the sort is to bring the most attention-grabbing colors to the right, and the least attention-grabbing to the left.
I wrote more comments as to what else you can adjust. For example, you can and should change the bg variable to match your terminal background.
You should consider your monitor's viewing angles. Make sure you're at the best angle.
It currently currently leverages implementation salience calculations, so there is no experimental local salience for more experimental calculations. I might add this in later if I deem that the component-delta model needs to be more complex, but considering Cam16's properties, it doesn't need to be... yet.
This PR doesn't HAVE to be merged in, as it's mainly just trying to determine the best weights for salience calculations, but if it does become merged, it can be leveraged to gather more data points on what might be the proper weights for this "salience" thing.
I will be experimenting in the coming days to determine the best weights. From brief experimentation, colorfulness or m needs a slight boost.
Here is a visual demo with normal generation and weights [1.0, 1.0, 1.0].
image
Notice how those pure white should be sorted later... and other incorrect sorting...