Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void FractalViewer::draw()
- {
- QEventLoop loop;
- aborted = false;
- actAbort->setEnabled(true);
- actDraw->setEnabled(false);
- double dx = (x2 - x1)/w;
- double dy = (y2 - y1)/h;
- double x = x1;
- double y = y1;
- Preferences dialog;
- if (checked)
- {
- QImage image(w, h, QImage::Format_RGB16);
- for (unsigned i = 0; i < w; i++)
- {
- x = x + dx;
- for (unsigned j = 0; j < h; j++)
- {
- y = y + dy;
- //image.setPixel(i, j, mandelbrot(x, y, iterations));
- //image.setPixelColor(i, j, mandelbrot2(Re, Im, iterations)); // WHAT IS THE RE IM FOR???
- image.setPixelColor(i, j, mandelbrot2(x, y, iterations));
- }
- loop.processEvents(QEventLoop::AllEvents);
- y = y1;
- if(aborted)
- break;
- }
- if(!aborted)
- {
- lblFractal->setPixmap(QPixmap::fromImage(image));
- lblFractal->adjustSize();
- statusBar()->showMessage(tr("Completed!"), 2500);
- }
- else
- {
- statusBar()->showMessage(tr("Aborted by user"), 2500);
- }
- }
- else
- {
- QImage image(w, h, QImage::Format_Mono);
- for (unsigned i = 0; i < w; i++)
- {
- x = x + dx;
- for (unsigned j = 0; j < h; j++)
- {
- y = y + dy;
- 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
- }
- loop.processEvents(QEventLoop::AllEvents);
- y = y1;
- if(aborted)
- break;
- }
- if(!aborted)
- {
- lblFractal->setPixmap(QPixmap::fromImage(image));
- lblFractal->adjustSize();
- statusBar()->showMessage(tr("Completed!"), 2500);
- }
- else
- {
- statusBar()->showMessage(tr("Aborted by user"), 2500);
- }
- }
- actAbort->setEnabled(false);
- actDraw->setEnabled(true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement