Class ColorMap

java.lang.Object
net.nullved.pmweatherapi.util.ColorMap

public class ColorMap extends Object
A builder-based representation of ColorTables. Should hopefully be able to produce identical results.

You can create a new ColorMap builder with ColorMap.Builder.of(Color). Use ColorMap.Builder.addPoint(Color, float) to add a new point to lerp between. Use ColorMap.Builder.override(Color, float) to add a new point to override the color at.
Since:
0.14.15.6
  • Method Details

    • minValue

      public float minValue()
      Gets the smallest value a color is defined for
      Returns:
      The minimum value
      Since:
      0.14.15.6
    • maxValue

      public float maxValue()
      Gets the largest value a color is defined for
      Returns:
      The maximum value
      Since:
      0.14.15.6
    • recomputeLookups

      public void recomputeLookups(float resolution)
      Recomputes the lookup table with the given resolution.
      Parameters:
      resolution - The new resolution
      Since:
      0.14.16.1
    • get

      public Color get(float val)
      Retrieves the color value using the closest value from the lookup table. If you need the accurate value, use getAccurate(float) instead
      Parameters:
      val - The value to get a color for
      Returns:
      The approximate color for this value
      Since:
      0.14.16.1
      See Also:
    • getAccurate

      public Color getAccurate(float val)
      Gets the Color for the specific value.
      This method is SLOWER and oftentimes the same as get(float). Use that instead if you only need the approximate value
      Parameters:
      val - The value to get the Color of
      Returns:
      The Color for the given value
      Since:
      0.14.15.6
      See Also:
    • lerp

      public static Color lerp(float delta, Color c1, Color c2)
      Lerps between two colors
      Parameters:
      delta - The t-value from 0 to 1
      c1 - The first Color
      c2 - The second Color
      Returns:
      A Color lerped between c1 and c2
      Since:
      0.14.15.6