コード例 #1
0
ファイル: ImageLabFrame.java プロジェクト: per-ola/db2004
  private Picture initialImage() {
    pic2 = new Picture(500, 600);
    pic1 = new Picture(500, 600);

    for (int x = 0; x < pic2.width(); x++)
      for (int y = 0; y < pic2.height(); y++) {
        double dist = 1.0 - Math.sqrt((x - 300) * (x - 300) + (y - 200) * (y - 200)) / 500;
        int red =
            (int)
                (dist < 0.5
                    ? 0
                    : Math.min(Math.pow(dist, 0.4) + Math.pow(dist - 0.5, 0.1), 1.0) * 255);
        int green = (int) (dist * 255);
        int blue = 0;
        pic2.set(x, y, new Color(red, green, blue));
      }
    return pic2;
  }