Class ColorInterpolator


  • public final class ColorInterpolator
    extends java.lang.Object
    Interpolate between two color values.

    Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
    BSD-style license. See OpenTrafficSim License.

    Version:
    $Revision: 4763 $, $LastChangedDate: 2018-11-19 11:04:56 +0100 (Mon, 19 Nov 2018) $, by $Author: averbraeck $, initial version 27 mei 2015
    Author:
    Peter Knoppers
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.awt.Color interpolateColor​(java.awt.Color zero, java.awt.Color one, double ratio)
      Generate a Color that is interpolated between two given Color values.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • interpolateColor

        public static java.awt.Color interpolateColor​(java.awt.Color zero,
                                                      java.awt.Color one,
                                                      double ratio)
        Generate a Color that is interpolated between two given Color values. Interpolation is simply done per channel (R, G, B).
        Parameters:
        zero - Color; the color that corresponds to ratio == 0
        one - Color; the color that corresponds to ratio == 1
        ratio - double; the ratio (should be between 0 and 1)
        Returns:
        Color; the interpolated color