FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Information Visualization
(Moderators: forkinsocket, REAS)
   real-time julia set (works)
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: real-time julia set (works)  (Read 695 times)
mm
Guest
Email
real-time julia set (works)
« on: Mar 21st, 2004, 10:28pm »

http://www.madmerv.com/proce55ing/julia2
 
Code:

/*
Julia.java - Java Julia by MN Karthik.  
Any questions, comments, suggestions? You can contact me at mnkarthik@yahoo.com.
 
Modifications and adaptation to Processing by Mad Merv 2004
http://www.madmerv.com
*/
 
   
void setup() {
   background(0);
   size(300,300);
   //noStroke();
}
 
void loop() {
  int sx=width;    //Screenwidth
  int sy=height;   //Screenheight
  double xmin=-(1.5);  //smallest real value (x-axis)
  double xmax=(1.5);   //largest real value (x-axis)
  double ymin=-(1.5);  //smallest imaginary value (y-axis)
  double ymax=(1.5);   //largest imaginary value (y-axis)
  double maxiter=512;   //Max number of iterations
 
  double old_x;    //temporary variable to store x-value
  double fx,fy;
  double ix=0.42;
  double iy=0.23;
  int m;      //variable to store number of iterations
 
  double dx=(xmax-xmin)/sx; //how much to add for each x-pixel?
  double dy=(ymax-ymin)/sy; //how much to add for each y-pixel?
 
  int px;     //Variable storing current x-pixel
  int py=0;   //Variable storing current y-pixel
  double x;   //Variable storing current x-value
  double y=ymin;   //Variable storing current y-value
 
 stroke(0);
  while (py<sy) {
  px=0;
  x=xmin;
  py++;
  while (px<sx) {
  px++;
 
  fx=x;
  fy=y;
  m=0;
  do {
    old_x=fx;
    fx= fx*fx - fy*fy + ix;
    fy= 2*old_x*fy + iy;
    m++;
  } while (((fx*fx+fy*fy)<4) && (m<maxiter));
    /*
  if (m%2==0) stroke(255,200,125);
     if (m%3==0) stroke(250,100,125);
     if (m%4==0) stroke(245,90,125);
     if (m%5==0) stroke(240,80,125);
     if (m%6==0) stroke(235,70,125);
     if (m%7==0) stroke(230,60,125);
     if (m%8==0) stroke(200,50,125);
     if (m%9==0) stroke(180,40,125);
     if (m%10==0) stroke(100,30,125);
     if (m%11==0) stroke(50,20,125);
     if (m%12==0) stroke(20,10,125);
     if (m%13==0) stroke(0);  
  */
  stroke(m%50+((mouseX+mouseY)/2),m%12*(255/12),m%4*(255/4));
  line(px-3,py-3,px+10,py+10);
  x+=dx;
  }
  y+=dy;
  }
  stroke(0);
}

 
 
 
Pages: 1 

« Previous topic | Next topic »