1
0
Fork 0

Field - grid color with alpha value

This commit is contained in:
rxbn_ 2019-12-13 01:35:49 +01:00
parent 7b416c205e
commit 463b562645
1 changed files with 10 additions and 0 deletions

View File

@ -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);
}
/**