Field - grid color with alpha value
This commit is contained in:
parent
7b416c205e
commit
463b562645
@ -140,6 +140,13 @@ public class Field extends JPanel {
|
||||
int blockWidth = Constants.SCREEN_WIDTH / Constants.SQUARES_X;
|
||||
int blockHeight = Constants.SCREEN_HEIGHT / Constants.SQUARES_Y;
|
||||
|
||||
// temporarily save default component color to draw ball in specific color
|
||||
Color temp = g2.getColor();
|
||||
|
||||
// Component color with alpha
|
||||
Color withAlpha = new Color(g2.getColor().getRed(), g2.getColor().getGreen(), g2.getColor().getBlue(), 170);
|
||||
g2.setColor(withAlpha);
|
||||
|
||||
// draw vertical lines
|
||||
for (int i = 1; i < Constants.SQUARES_X; i++) {
|
||||
g2.drawLine(i * blockWidth, 0, i * blockWidth, Constants.SCREEN_HEIGHT);
|
||||
@ -149,6 +156,9 @@ public class Field extends JPanel {
|
||||
for (int i = 1; i < Constants.SQUARES_Y; i++) {
|
||||
g2.drawLine(0, i * blockHeight, Constants.SCREEN_WIDTH, i * blockHeight);
|
||||
}
|
||||
|
||||
// reset color to default
|
||||
g2.setColor(temp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user