Reputation: 123
I am making a drawing tool in java, but the orange is seems a bit too light.
Where to put the color name at the function public Color darker()
?
public void clear() {
g2.setPaint(Color.white);
// draw white on entire draw area to clear
g2.fillRect(0, 0, getSize().width, getSize().height);
g2.setPaint(Color.black);
repaint();
}
public void red() {
// apply red color on g2 context
g2.setPaint(Color.red);
}
public void black() {
g2.setPaint(Color.black);
}
public void magenta() {
g2.setPaint(Color.magenta);
}
public void green() {
g2.setPaint(Color.green);
}
public void blue() {
g2.setPaint(Color.blue);
}
public void yellow() {
g2.setPaint(Color.yellow);
}
public void orange() {
g2.setPaint(Color.orange.darker);
}
}
Please tell me what to write to make the orange darker.
Upvotes: 2
Views: 14109
Reputation: 6077
You can do:
Color.ORANGE.darker()
or
Color.orange.darker()
Also, if you still think that it is not dark enough, you can even do:
Color.orange.darker().darker().darker().darker().darker() // as many times as you want!
Also, the default orange color, as defined in the class is:
new Color(255, 200, 0)
If you want, you may do something with those numbers!
In your code, change this line:
g2.setPaint(Color.orange.darker);
to
g2.setPaint(Color.orange.darker()); // darker ain't a var, it is a method.
And,
drawArea.orange.darker();
to
drawArea.orange(); //You cannot call darker() on void!
Upvotes: 11
Reputation: 21
Here is what I created:
public static int darker (int color, float factor) {
int a = Color.Orange( color );
return Color.argb( a,
Math.max( (int)(r * factor), 0 ));
}
Upvotes: -1