static <C extends TextColor> @NotNull C nearestColorTo(final @NotNull List<C> values, final @NotNull TextColor any) {
    requireNonNull(any, "color");

    float matchedDistance = Float.MAX_VALUE;
    C match = values.get(0);
    for (int i = 0, length = values.size(); i < length; i++) {
      final C potential = values.get(i);
      final float distance = TextColorImpl.distance(any.asHSV(), potential.asHSV());
      if (distance < matchedDistance) {
        match = potential;
        matchedDistance = distance;
      }
      if (distance == 0) {
        break; // same colour! whoo!
      }
    }
    return match;
  }
Find the colour nearest to the provided colour.

@param values the colours for matching
@param any colour to match
@param <C> the color type
@return nearest named colour. will always return a value
@since 4.14.0
api/src/main/java/net/kyori/adventure/text/format/TextColor.java