Currently I am working on a simulation project using javax.swing and I want to draw "grass" on my map based on it's food value. My food value is a double between 0 < 1, and I want to make it brighter as it gets bigger. I have been reading about HSB/HSV but cannot figure out how it works / the syntax of it. What is a good solution to this problem? Or can someone direct me somewhere that has a good tutorial?
class Grass{
private void setColor(){
grassColor = new Color(107, 142, 35); //RGB value I want to start with as "dead grass"
}
public Color getColor(){
return grassColor; //this is what i want to change based on food value;
}
private double growthRate = 0.1;
public void grow(){
foodValue += (foodValue < 1.0) ? growthRate : 0; //grows the grass to max size of 1.0
}
I guess I should also mention my food value is set to a random float when it initializes. Appreciate any advice.