daily pastebin goal
51%
SHARE
TWEET

Untitled

a guest Apr 22nd, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top