On Mon, Jun 07, 2004 at 12:00:19PM +0800, [EMAIL PROTECTED] wrote: > Hi - > > Slightly off topic but, > > I am making an application that will display a heat map based on the value > of a variable. I'm wondering if anyone has some sample code for generating > a color on a gradient between color a and color b (red and green are > traditional but something generic would be nice) based on the value of the > variable? > > I guess this is the sort of thing you use for microarray displays/ > correlations etc. Cellular automata in this case but it should be useful > to others in the list.
This is pretty straightforward in Java, for instance: public Color mixColor(Color from, Color to, double amount) { float x = (float) amount; float y = (float) (1.0 - amount); return new Color((int) (y * from.getRed() + x * to.getRed()), (int) (y * from.getGreen() + x * to.getGreen()), (int) (y * from.getBlue() + x * to.getBlue())); } This is nice for 'fluffy' viewing of new data, but for serious analysis I'd agree with Dan's point about using a discrete scale instead. Thomas. _______________________________________________ Biojava-l mailing list - [EMAIL PROTECTED] http://biojava.org/mailman/listinfo/biojava-l