Back to top

f02b

  • Wielkość pliku: 6,3MB

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

public class f02b
{
	
	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 = -500;
		double yl = -500;
		double xr = 500;
		double yr = 500;

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

		for(int i = 0; i < I; ++i) 
		{ 
						
				int x2 = (int)(A * x + B);
				int y2 = (int)(C * y + D);
				
				z = (z+1) & 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.sin(x * y) + y;
			y = 3.9 - x;
			x = x1;	
		}
		
		return image;
	}
}