Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.14 KB | None | 0 0
  1. void FractalViewer::draw()
  2. {
  3.     QEventLoop loop;
  4.     aborted = false;
  5.     actAbort->setEnabled(true);
  6.     actDraw->setEnabled(false);
  7.     double dx = (x2 - x1)/w;
  8.     double dy = (y2 - y1)/h;
  9.     double x = x1;
  10.     double y = y1;
  11.  
  12.     Preferences dialog;
  13.     if (checked)
  14.     {
  15.         QImage image(w, h, QImage::Format_RGB16);
  16.         for (unsigned i = 0; i < w; i++)
  17.         {
  18.             x = x + dx;
  19.             for (unsigned j = 0; j < h; j++)
  20.             {
  21.                 y = y + dy;
  22.                 //image.setPixel(i, j, mandelbrot(x, y, iterations));
  23.                 //image.setPixelColor(i, j, mandelbrot2(Re, Im, iterations)); // WHAT IS THE RE IM FOR???
  24.                 image.setPixelColor(i, j, mandelbrot2(x, y, iterations));
  25.             }
  26.             loop.processEvents(QEventLoop::AllEvents);
  27.             y = y1;
  28.             if(aborted)
  29.                 break;
  30.         }
  31.         if(!aborted)
  32.         {
  33.             lblFractal->setPixmap(QPixmap::fromImage(image));
  34.             lblFractal->adjustSize();
  35.             statusBar()->showMessage(tr("Completed!"), 2500);
  36.         }
  37.         else
  38.         {
  39.             statusBar()->showMessage(tr("Aborted by user"), 2500);
  40.         }
  41.     }
  42.     else
  43.     {
  44.         QImage image(w, h, QImage::Format_Mono);
  45.         for (unsigned i = 0; i < w; i++)
  46.         {
  47.             x = x + dx;
  48.             for (unsigned j = 0; j < h; j++)
  49.             {
  50.                 y = y + dy;
  51.                 image.setPixel(i, j, mandelbrot(x, y, iterations)); // i j zustane stejny, tu fci mandelbrot musime upravit, tak, aby vracela neco mezi nulou a 255, index te barvy
  52.             }
  53.             loop.processEvents(QEventLoop::AllEvents);
  54.             y = y1;
  55.             if(aborted)
  56.                 break;
  57.         }
  58.         if(!aborted)
  59.         {
  60.             lblFractal->setPixmap(QPixmap::fromImage(image));
  61.             lblFractal->adjustSize();
  62.             statusBar()->showMessage(tr("Completed!"), 2500);
  63.         }
  64.         else
  65.         {
  66.             statusBar()->showMessage(tr("Aborted by user"), 2500);
  67.         }
  68.     }
  69.     actAbort->setEnabled(false);
  70.     actDraw->setEnabled(true);
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement