Here you can find the source of blend(final Color color1, final Color color2, final double ratio)
public static Color blend(final Color color1, final Color color2, final double ratio)
//package com.java2s; //License from project: Open Source License import java.awt.Color; import java.text.NumberFormat; public class Main { public static Color blend(final Color color1, final Color color2, final double ratio) { final float r = (float) ratio; final float ir = (float) 1.0 - r; final float rgb1[] = new float[3]; final float rgb2[] = new float[3]; color1.getColorComponents(rgb1); color2.getColorComponents(rgb2); float red = rgb1[0] * r + rgb2[0] * ir; float green = rgb1[1] * r + rgb2[1] * ir; float blue = rgb1[2] * r + rgb2[2] * ir; if (red < 0) { red = 0;/*from w w w . ja v a 2 s. co m*/ } else if (red > 255) { red = 255; } if (green < 0) { green = 0; } else if (green > 255) { green = 255; } if (blue < 0) { blue = 0; } else if (blue > 255) { blue = 255; } Color color = null; try { color = new Color(red, green, blue); } catch (final IllegalArgumentException exp) { final NumberFormat nf = NumberFormat.getNumberInstance(); System.out.println(nf.format(red) + "; " + nf.format(green) + "; " + nf.format(blue)); exp.printStackTrace(); } return color; } }