Back to top

f03

  • Wielkość pliku: 6,1MB

import java.awt.Color;
import java.awt.image.*;


/* Duch */
public class f03
{
	
	public BufferedImage draw()
	{
		int I = 10000000;
		int WIDTH = 5000; 
		int HEIGHT = 5000;
		int IMG_TYPE = java.awt.image.BufferedImage.TYPE_INT_RGB;
		
		BufferedImage image = new BufferedImage(WIDTH, HEIGHT, IMG_TYPE);
		
		ColorModel model = image.getColorModel(); 
		WritableRaster raster = image.getRaster();
		
		Color fcolor; 

		double x1, x = 0;
		double y = 0;

		int z = 0;
				
		// Skalowanie
	
		double xl = -20;
		double yl = -20;
		double xr = 20;
		double yr = 20;

		double A = WIDTH / (xr - xl);
		double B = -A * xl;
		double C = HEIGHT / (yl - yr);
		double D = -C * yr;

		//System.out.println(":: " + A + ", " + B + ", " + C + ", " + D);
		
		for(int i = 0; i < I; ++i) 
		{ 						
				int x2 = (int)(A * x + B);
				int y2 = (int)(C * y + D);
				
				z = (z + 100) & 0xffffff;
				
				fcolor = new Color(z);
				
				if(x2 < WIDTH && y2 < HEIGHT && x2 > 0 && y2 > 0)
				{
					raster.setDataElements(x2, y2, 
							model.getDataElements(fcolor.getRGB(), null));
				}
				
			x1 = Math.log(1+x*x) + 1.000003 * y;
			y = 3 - x;
			x = x1;	
		}
		
		return image;
	}
}