Example #1
0
  private void renderBlackout(Graphics g, int x, int y, int radius) {
    if (radius > 320) return;

    int[] xp = new int[20];
    int[] yp = new int[20];
    for (int i = 0; i < 16; i++) {
      xp[i] = x + (int) (Math.cos(i * Math.PI / 15) * radius);
      yp[i] = y + (int) (Math.sin(i * Math.PI / 15) * radius);
    }
    xp[16] = 320;
    yp[16] = y;
    xp[17] = 320;
    yp[17] = 240;
    xp[18] = 0;
    yp[18] = 240;
    xp[19] = 0;
    yp[19] = y;
    g.fillPolygon(xp, yp, xp.length);

    for (int i = 0; i < 16; i++) {
      xp[i] = x - (int) (Math.cos(i * Math.PI / 15) * radius);
      yp[i] = y - (int) (Math.sin(i * Math.PI / 15) * radius);
    }
    xp[16] = 320;
    yp[16] = y;
    xp[17] = 320;
    yp[17] = 0;
    xp[18] = 0;
    yp[18] = 0;
    xp[19] = 0;
    yp[19] = y;

    g.fillPolygon(xp, yp, xp.length);
  }