Here you can find the source of generateColorRamp(int n)
Parameter | Description |
---|---|
n | a parameter |
public static Color[] generateColorRamp(int n)
//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; } }