Class ColorUtils

java.lang.Object
com.arbergashi.charts.util.ColorUtils

public final class ColorUtils extends Object
Color utilities.
Since:
2025-06-01
Version:
1.0.0
Author:
Arber Gashi
  • Method Details

    • withAlpha

      public static Color withAlpha(Color c, float alpha)
      Creates a new color based on c, but with a new alpha value.

      Note: Creates a new object. Should be cached in render loops if the color does not change.

      Parameters:
      c - Base color
      alpha - Alpha (0.0 - 1.0)
      Returns:
      New Color instance
    • adjustBrightness

      public static Color adjustBrightness(Color c, double factor)
      Adjust brightness by multiplying RGB channels by factor (>0). Clamps to 0-255.
    • getContrastColor

      public static Color getContrastColor(Color c)
      Returns BLACK or WHITE depending on which contrasts better with the input color.
    • interpolate

      public static Color interpolate(Color a, Color b, float t)
      Linearly interpolate between two colors in RGBA space.