Java examples for 2D Graphics:Color Blend
generate Rainbow Color
//package com.java2s; import java.awt.*; public class Main { public static Color generateRainbow(int number, int total) { int gr = Math.abs(128 - number * 255 / total); int re = 255 - number * 255 / total; int bl = number * 255 / total; try {//from w w w .ja v a 2 s.c o m return new Color(re, gr, bl); } catch (IllegalArgumentException e) { return Color.BLACK; } } }