Wysłane przez lukasz w
- Wielkość pliku: 2,3MB
import java.awt.Color;
import java.awt.image.*;
import java.util.Random;
/* Smok */
public class f04
{
public BufferedImage draw()
{
int I = 100000000;
int WIDTH = 10000;
int HEIGHT = 10000;
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]);
// maksymalna ilosc przeksztalcen
int MIP = 2;
double[] AA = {0.824074, 0.088272};
double[] AB = {0.281482, 0.520988};
double[] AC = {-0.212346, -0.463889};
double[] AD = {0.864198, -0.377778};
double[] AE = {-1.88229, 0.78536};
double[] AF = {-0.110607, 8.095795};
// Skalowanie
double xl = -6.5;
double yl = -1.5;
double xr = 6.5;
double yr = 11.5;
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;
}
}
