Back to top

f02

  • Wielkość pliku: 7,5MB

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

public class f02
{
	
	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; 
		fcolor = new Color(z);
		
		// Skalowanie
	
		double xl = -3000;
		double yl = -3000;
		double xr = 3000;
		double yr = 3000;

		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 + 10) & 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;
	}
}