Select Colorful Bukkit Colors
ColorfulnessFinder is a small Reedwork utility for selecting the two most colorful Bukkit Color values from a collection of candidates.
It evaluates each color using HSL saturation and lightness, ranks the candidates by its colorfulness score, and returns the two highest-scoring colors.
This is useful when an application needs to reduce a larger color palette to two visually strong colors.
Find two signal colors
Section titled “Find two signal colors”getTwoSignalColors(Color[] colors)
Section titled “getTwoSignalColors(Color[] colors)”Pass an array of Bukkit Color values to getTwoSignalColors(...):
Color[] colors = { Color.fromRGB(255, 0, 0), Color.fromRGB(0, 255, 0), Color.fromRGB(0, 0, 255), Color.fromRGB(128, 128, 128)};
Color[] signalColors = ColorfulnessFinder.getTwoSignalColors(colors);
Color first = signalColors[0];Color second = signalColors[1];The method returns exactly two colors.
The first result has the highest colorfulness score and the second result has the second-highest score.
How colorfulness is calculated
Section titled “How colorfulness is calculated”ColorfulnessFinder converts each RGB color into the HSL color model.
The colorfulness score is calculated as:
colorfulness = saturation × lightness
Higher saturation increases the score, while lightness affects the resulting value.
The candidate colors are then ordered by their score in descending order.
The two highest-scoring colors are returned.
Example
Section titled “Example”For example, given several candidate colors:
Color[] colors = { Color.fromRGB(255, 0, 0), Color.fromRGB(100, 100, 100), Color.fromRGB(0, 180, 255), Color.fromRGB(40, 40, 40)};
Color[] result = ColorfulnessFinder.getTwoSignalColors(colors);result[0] contains the highest-scoring candidate and result[1] contains the second-highest candidate according to the utility’s colorfulness calculation.
The input array is not modified.
Use ColorfulnessFinder with ColorUtils
Section titled “Use ColorfulnessFinder with ColorUtils”ColorfulnessFinder is particularly useful together with ColorUtils.
For example, an application can first select two strong colors and then use them to generate an Adventure text gradient:
Color[] candidates = { Color.fromRGB(255, 80, 80), Color.fromRGB(80, 255, 80), Color.fromRGB(80, 80, 255), Color.fromRGB(120, 120, 120)};
Color[] signalColors = ColorfulnessFinder.getTwoSignalColors(candidates);
Component gradient = ColorUtils.generateGradientText( "Welcome!", signalColors[0], signalColors[1] );This separates the two operations:
ColorfulnessFinderselects the strongest candidate colors.ColorUtilsapplies those colors to Adventure text.
For image-based color extraction, see extractTwoColors in ColorUtils.
getTwoSignalColors(Color[] colors)
Section titled “getTwoSignalColors(Color[] colors)”Finds the two colors with the highest colorfulness scores.
| Parameter | Type | Description |
|---|---|---|
colors |
Color[] |
The candidate colors to evaluate. |
The input array must contain at least two colors.
Returns:
An array containing exactly two colors:
| Index | Description |
|---|---|
0 |
The color with the highest colorfulness score. |
1 |
The color with the second-highest colorfulness score. |
When to use ColorfulnessFinder
Section titled “When to use ColorfulnessFinder”Use ColorfulnessFinder when your application already has multiple candidate colors and needs to select two visually strong colors.
Typical use cases include:
- reducing an image-derived color palette;
- selecting colors for gradients;
- generating dynamic UI colors;
- choosing representative colors from a collection.
For general Bukkit color operations, see Color Utilities.
Summary
Section titled “Summary”ColorfulnessFinder provides a focused color-selection operation for Bukkit colors.
It:
- converts RGB colors into HSL;
- calculates a colorfulness score from saturation and lightness;
- ranks candidate colors by that score;
- returns the two highest-scoring colors;
- can be combined with
ColorUtilsfor gradient generation.
For the complete collection of Reedwork utilities, see the PaperMC Plugin Utilities.