Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <QApplication>
- #include <QImage>
- #include <QLabel>
- #include <complex>
- #include <cmath>
- // Функція для обчислення Множини Жюльї з використанням tg(z)
- void computeJuliaSet(QImage &image) {
- int width = image.width();
- int height = image.height();
- double maxIter = 256;
- for (int x = 0; x < width; x++) {
- for (int y = 0; y < height; y++) {
- std::complex<double> z(0, 0);
- std::complex<double> c(
- 2.0 * (x - width / 2) / (width - 1),
- 2.0 * (y - height / 2) / (height - 1)
- );
- int iter = 0;
- while (iter < maxIter && std::abs(z) < 2.0) {
- z = std::tan(z) + c;
- iter++;
- }
- if (iter < maxIter) {
- // Колір для точки, яка не підлягає обмеженню
- image.setPixel(x, y, qRgb(iter * 8, iter * 4, iter * 16));
- } else {
- // Колір для точки, яка підлягає обмеженню
- image.setPixel(x, y, qRgb(0, 0, 0));
- }
- }
- }
- }
- int main(int argc, char *argv[]) {
- QApplication app(argc, argv);
- int width = 800;
- int height = 800;
- QImage image(width, height, QImage::Format_RGB32);
- computeJuliaSet(image);
- QLabel label;
- label.setPixmap(QPixmap::fromImage(image));
- label.show();
- return app.exec();
- }
Advertisement
Add Comment
Please, Sign In to add comment