ColorUtil { public static Color colorLerp(final Color a, final Color b, final double t) { final double r1 = a.getRed(); final double r2 = b.getRed(); final double g1 = a.getGreen(); final double g2 = b.getGreen(); final double b1 = a.getBlue(); final double b2 = b.getBlue(); return new Color( (int) Math.round(r1 + (t * (r2 - r1))), (int) Math.round(g1 + (t * (g2 - g1))), (int) Math.round(b1 + (t * (b2 - b1))) ); }  static String colorTag(Color color); static String prependColorTag(final String str, final Color color); static String wrapWithColorTag(final String str, final Color color); static String toHexColor(final Color color); static Color colorLerp(final Color a, final Color b, final double t); static String colorToHexCode(final Color color); static String colorToAlphaHexCode(final Color color); static boolean isAlphaHex(String hex); static boolean isHex(String hex); static int constrainValue(int value); static Color fromString(String string); static Color fromHex(String hex); static Color fromObject(@Nonnull final Object object); static final int MAX_RGB_VALUE; static final int MIN_RGB_VALUE; static final String CLOSING_COLOR_TAG; }
@Test public void colorLerp() { assertEquals(Color.WHITE, ColorUtil.colorLerp(Color.WHITE, Color.WHITE, 0.9)); assertEquals(new Color(128, 128, 128), ColorUtil.colorLerp(Color.BLACK, Color.WHITE, 0.5)); assertEquals(Color.BLACK, ColorUtil.colorLerp(Color.BLACK, Color.CYAN, 0)); assertEquals(Color.CYAN, ColorUtil.colorLerp(Color.BLACK, Color.CYAN, 1)); }