So I have made a health bar that changes colour depending on the health of the individual. But I wanna make it so that when the player walks under the health bar, it turns it translucent and I am wondering how do I do that if the health bar is made out of HSB colour?
private static float HEALTH = 100;
public void render(Graphics g) {
g.setColor(Color.GRAY);
g.fillRect(15, 15, 200, 32);
color = Color.getHSBColor( (1f * HEALTH) / 360, 1f, 1f);
g.setColor(Color.getHSBColor( (1f * HEALTH) / 360, 1f, 1f));
g.fillRect(15, 15, (int) HEALTH * 2, 32);
g.setColor(Color.white);
g.drawRect(15, 15, 200, 32);
}