Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Mandelbrot(int rows, int cols, Complex topLeftCorner, double xStepSize, double yStepSize, int maxIterations, RGBColor[] palette){
- Complex[][] plane = new Complex[rows][cols];
- for (int i=0;i<rows;i++){
- for (int j=0;j<cols;j++){
- Complex deltaFromTopLeft = new Complex(j*xStepSize,-i*yStepSize);
- plane[i][j]= topLeftCorner.plus(deltaFromTopLeft);
- }
- }
- complex = plane;
- // this is a shallow copy, do a deep copy
- this.palette = palette;
- this.rows = rows;
- this.cols = cols;
- this.maxIterations=maxIterations;
- }
- public RGBImage getImage(){
- image = new RGBImage(rows, cols);
- for (int i=0;i<rows;i++){
- for (int j=0;j<cols;j++){
- int paletteIndex = complex[i][j].escapeTime(RADIUS, maxIterations);
- if (paletteIndex==-1){
- paletteIndex=0;
- }
- image.setPixel(i, j, palette[paletteIndex]);
- }
- }
- return image;
- }
- }
Add Comment
Please, Sign In to add comment