Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- class Pixel{
- static String kolor(int n){
- double R=(255.-255.*Math.pow(0.9,n));
- double G=(255.-100.*Math.pow(0.97,n));
- double B=(255.-60.*Math.pow(0.88,n));
- return (int)R+" "+(int)G+" "+(int)B+"\n";
- }
- }
- class Mandelbrot {
- static void create(int SZER, int WYS, int MAX){
- double x,y;
- int k;
- BufferedWriter writer = null;
- try
- {
- writer = new BufferedWriter( new FileWriter("mandel.ppm"));
- writer.write("P3\n# obraz\n"+SZER+" "+WYS+"\n255\n");
- for(y=-1.25;y<1.25;y=y+(2.5/WYS))
- {
- for(x=-2.;x<1.;x=x+(3./SZER))
- {
- Complex c=new Complex(x,y);
- k=0;
- for(Complex z=new Complex(0.,0.);Complex.abs(z)<2. && k<MAX;k++)
- z=Complex.add(Complex.pow(z,2),c);
- writer.write(Pixel.kolor(k));
- }
- }
- }
- catch ( IOException e)
- {
- }
- finally
- {
- try
- {
- if ( writer != null)
- writer.close( );
- }
- catch ( IOException e)
- {
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment