meshHullSamples function

List<int> meshHullSamples(
  1. List<int> stops
)

The colour hull of a mesh with opaque stops, sampled: every stop, every pairwise ¼ / ½ / ¾ point and every three-way centroid, blended in encoded sRGB (integer arithmetic, bit-exact). The darkest and lightest colours a mesh can paint are among (or within a hair of) these.

Implementation

List<int> meshHullSamples(List<int> stops) {
  final out = <int>[...stops];
  final n = stops.length;
  for (var i = 0; i < n; i++) {
    for (var j = i + 1; j < n; j++) {
      for (var k = 1; k <= 3; k++) {
        out.add(_mix(stops[i], stops[j], 4 - k, k, 4));
      }
    }
  }
  for (var i = 0; i < n; i++) {
    for (var j = i + 1; j < n; j++) {
      for (var k = j + 1; k < n; k++) {
        out.add(_centroid(stops[i], stops[j], stops[k]));
      }
    }
  }
  return out;
}