javascript - Julia set rendering code not working -


i'm working on mandelbrot , julia set renderer in javascript. done mandelbrot set, , assumed julia sets natural extension of that. however, current implementation of julia sets seems not working. have following:

for(var row=0; row < height; row ++) {      for(var col=0; col < width; col ++) {          var re = parsefloat(document.getelementbyid("jul_0").value);         var im = parsefloat(document.getelementbyid("jul_1").value);          var x = (col - width/2)*4.0/width;         var y = (row - height/2)*4.0/width;          var iterations = 0;          while(((x*x + y*y) <= 4) && (iterations < max)) {              var tmp = x*x - y*y + re;             y = 2*x*y - im;             x = tmp;              iterations ++;          }          if(iterations < max) {              ctx.fillstyle = colors[iterations];             ctx.fillrect(col, row, 1, 1);          } else {              ctx.fillstyle = "#000000";             ctx.fillrect(col, row, 1, 1);          }     }  } 

assume here jul_0 , jul_1 real , imaginary parts of c, respectively. max maximum number of iterations, , colors array of colors of length max. (x,y) starting value of z0.

currently, program quite literally nothing, skipping else clause every value of (x,y). feel due obvious mistake, i'm not sure.

additionally, seeing values of max (which given input) rendering runs instantaneously, i'm led believe it's skipping loop entirely.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -