Java Color Create generateColorRamp(int n)

Here you can find the source of generateColorRamp(int n)

Description

Generates a red to blue color ramp with of 'n' colors

License

Open Source License

Parameter

Parameter Description
n a parameter

Declaration

public static Color[] generateColorRamp(int n) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (C) 2010 Lucas Madar and Peter Brewer
 * /*from   w  w  w .j ava2 s  . c  o m*/
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Contributors:
 *     Lucas Madar
 *     Peter Brewer
 ******************************************************************************/

import java.awt.Color;

public class Main {
    /**
    * Generates a red to blue color ramp with of 'n' colors
    * 
    * @param n
    * @return
    */
    public static Color[] generateColorRamp(int n) {
        Color[] cols = new Color[n];
        for (int i = 0; i < n; i++) {
            cols[i] = Color.getHSBColor((float) i / (float) (n * 1.5), 0.75f, 1.0f);
        }
        return cols;
    }
}

Related

  1. colorWithIntAndAlpha(int color, int alpha)
  2. generateBlankImage(int w, int h, Color col)
  3. generateColor(int fc, int bc)
  4. generateColorFromString(String seed)
  5. generateColorModel()
  6. generateColourSet(Color[] palette, int numColorBands)
  7. generateFireMapColor(double min, double max, double value)
  8. generateGrayScaleColor(double min, double max, double value)
  9. generateGreyColor(double value, double minValue, double maxValue)