コード例 #1
0
  /**
   * Makes the Mandelbrot image.
   *
   * @param width the width
   * @parah height the height
   * @return the image
   */
  public BufferedImage makeMandelbrot(int width, int height) {
    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    WritableRaster raster = image.getRaster();
    ColorModel model = image.getColorModel();

    Color fractalColor = Color.red;
    int argb = fractalColor.getRGB();
    Object colorData = model.getDataElements(argb, null);

    for (int i = 0; i < width; i++)
      for (int j = 0; j < height; j++) {
        double a = XMIN + i * (XMAX - XMIN) / width;
        double b = YMIN + j * (YMAX - YMIN) / height;
        if (!escapesToInfinity(a, b)) raster.setDataElements(i, j, colorData);
      }
    return image;
  }