예제 #1
0
파일: Circle.java 프로젝트: st33v3/J11
  public void erase(gnu.app.displayhack.DisplayHack hack) {
    gnu.x11.Window window = hack.window;

    /* Minimum radius = L/sqrt(2) ~= 0.707*L,
     *   where L = max(width, heigth)
     *         sqrt(2) = 1.414213562373095
     *
     * Take radius = L for faster (easier) computation.
     */
    int radius = Math.max(window.width, window.height);

    int full = 360 * 64;
    int delta = (full / 200) * hack.eraser_delta;
    int step_count = (int) Math.ceil(1 + full / delta);
    int start = hack.random.nextInt(full);

    // clockwise or counter-clockwise
    if (hack.random.nextBoolean()) delta = -delta;

    for (int i = 0; i < step_count; i++) {
      window.fill_arc(
          hack.display.default_gc,
          window.width / 2 - radius,
          window.height / 2 - radius,
          2 * radius,
          2 * radius,
          (start + i * delta) % full,
          delta);

      if (sleep(hack)) return;
    }

    hack.sleep(hack.delay / 2); // before next screen
  }