Wysłane przez lukasz w
- Wielkość pliku: 264KB
import java.awt.Color; import java.awt.image.*; import java.util.Random; public class f06 { public BufferedImage draw() { int I = 100000000; int WIDTH = 2500; 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[] AZ = {0x0, 0xffffff}; fcolor = new Color(AZ[1]); int MIP=4; double[] AA = {0, 0.85, 0.2, -0.15}; double[] AB = {0, 0.04, -0.26, 0.28}; double[] AC = {0, -0.04, 0.23, 0.26}; double[] AD = {0.16, 0.85, 0.22, 0.24}; double[] AE = {0, 0, 0, 0}; double[] AF = {0, 1.6, 1.6, 0.44}; // Skalowanie double xl = -3; double yl = 0; double xr = 3; double yr = 10; double A = WIDTH / (xr - xl); double B = -A * xl; double C = HEIGHT / (yl - yr); double D = -C * yr; Random random = new Random(); int RAND = 0; for(int i = 0; i < I; i++) { RAND = random.nextInt(MIP); x1 = AA[RAND] * x + AB[RAND] * y + AE[RAND]; y = AC[RAND] * x + AD[RAND] * y + AF[RAND]; x = x1; // punkt na płótno int x2 = (int)(A * x + B); int y2 = (int)(C * y + D); if(x2 < WIDTH && y2 < HEIGHT && x2 >= 0 && y2 >= 0) { raster.setDataElements(x2, y2, model.getDataElements(fcolor.getRGB(), null)); } } return image; } }