private void drawBlocks(Graphics2D g2) {
        g2.fillRect(0, 0, size.width, size.height);
        for (int y = 0; y < grid.height; y++) {
            double f = (double) y / grid.height;
            int green = (int) (120 + f * (240 - 120));
            int red = (int) (120 + (1-f) * (240 - 120));
            Color blockColor = new Color(red, green, 100);
            for (int x = 0; x < grid.width; x++) {
                if (grid.get(x, y)) {
                    g2.setPaint(new GradientPaint(
                            x * BLOCK_SIZE, y * BLOCK_SIZE, blockColor,
                            (x + 1) * BLOCK_SIZE, (y + 1) * BLOCK_SIZE, blockColor.darker())
                    );
                    g2.fillRect(x * BLOCK_SIZE, y * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE);
                    g2.setPaint(null);
                }
            }
        }
    }