progs/mandelbrot.scala
changeset 167 349d706586ef
parent 166 780c40aaad27
child 174 90e0b1cc460b
equal deleted inserted replaced
166:780c40aaad27 167:349d706586ef
    73   viewer.clearCanvas(black)
    73   viewer.clearCanvas(black)
    74    
    74    
    75   val delta_x = (end.a - start.a) / W
    75   val delta_x = (end.a - start.a) / W
    76   val delta_y = (end.b - start.b) / H
    76   val delta_y = (end.b - start.b) / H
    77    
    77    
    78   for (y0 <- (0 until H).par) {
    78   for (y0 <- (0 until H)) {
    79     for (x0 <- (0 until W).par) {
    79     for (x0 <- (0 until W)) {
    80     
    80     
    81      val c = start + Complex(x0 * delta_x, y0 * delta_y)
    81      val c = start + Complex(x0 * delta_x, y0 * delta_y)
    82 
    82 
    83      def iters(z: Complex, it: Int) : Color = {
    83      def iters(z: Complex, it: Int) : Color = {
    84        if (it < level && z.abs < 2) iters(z * z + c, it + 1) else 
    84        if (it < level && z.abs < 2) iters(z * z + c, it + 1) else 
   122 //time_needed(mandelbrot(exc1, exc2, 1000))
   122 //time_needed(mandelbrot(exc1, exc2, 1000))
   123 
   123 
   124 // some more computations with example 3
   124 // some more computations with example 3
   125 val delta = (exc2 - exc1) * 0.0333
   125 val delta = (exc2 - exc1) * 0.0333
   126 
   126 
   127 //time_needed(
   127 time_needed(
   128 //  for (i <- (0 to 12)) 
   128   for (i <- (0 to 12)) 
   129 //     mandelbrot(exc1 + delta * i, 
   129      mandelbrot(exc1 + delta * i, 
   130 //                exc2 - delta * i, 1000))
   130                 exc2 - delta * i, 1000))val exc1 = Complex(0.435396403, 0.367981352)
       
   131 val exc2 = Complex(0.451687191, 0.380210061)
       
   132 
       
   133 //time_needed(mandelbrot(exc1, exc2, 1000))
       
   134 
       
   135 // some more computations with example 3
       
   136 val delta = (exc2 - exc1) * 0.0333
       
   137 
       
   138 time_needed(
       
   139   for (i <- (0 to 12)) 
       
   140      mandelbrot(exc1 + delta * i, 
       
   141                 exc2 - delta * i, 1000))
   131 
   142 
   132 
   143 
   133 
   144