コード例 #1
0
 public void setStops(final List<Stop> STOPS) {
   stops.clear();
   for (Stop stop : STOPS) {
     stops.put(stop.getOffset(), stop);
   }
   init();
 }
コード例 #2
0
 public GradientLookup(final Stop... STOPS) {
   stops = new TreeMap<>();
   for (Stop stop : STOPS) {
     stops.put(stop.getOffset(), stop);
   }
   init();
 }
コード例 #3
0
  private Color interpolateColor(
      final Stop LOWER_BOUND, final Stop UPPER_BOUND, final double POSITION) {
    final double POS =
        (POSITION - LOWER_BOUND.getOffset()) / (UPPER_BOUND.getOffset() - LOWER_BOUND.getOffset());

    final double DELTA_RED =
        (UPPER_BOUND.getColor().getRed() - LOWER_BOUND.getColor().getRed()) * POS;
    final double DELTA_GREEN =
        (UPPER_BOUND.getColor().getGreen() - LOWER_BOUND.getColor().getGreen()) * POS;
    final double DELTA_BLUE =
        (UPPER_BOUND.getColor().getBlue() - LOWER_BOUND.getColor().getBlue()) * POS;
    final double DELTA_OPACITY =
        (UPPER_BOUND.getColor().getOpacity() - LOWER_BOUND.getColor().getOpacity()) * POS;

    double red = Helper.clamp(0d, 1d, (LOWER_BOUND.getColor().getRed() + DELTA_RED));
    double green = Helper.clamp(0d, 1d, (LOWER_BOUND.getColor().getGreen() + DELTA_GREEN));
    double blue = Helper.clamp(0d, 1d, (LOWER_BOUND.getColor().getBlue() + DELTA_BLUE));
    double opacity = Helper.clamp(0d, 1d, (LOWER_BOUND.getColor().getOpacity() + DELTA_OPACITY));

    return Color.color(red, green, blue, opacity);
  }