I wrote a library similar to what you describe for matlab in java: http://www.dishevelled.org/color-scheme/