5 * 1. Créer le fichier hello.pro :
6 * +------------------------------------------------------------+
8 * |CONFIG += qt debug |
9 * |SOURCES += hello.cc |
10 * +------------------------------------------------------------+
12 * 2. Créer le fichier Makefile avec la commande :
13 * $ qmake -makefile hello.pro
14 * ou tout simplement :
17 * 3. Compiler avec la commande :
24 #include <QApplication>
25 #include <DrawingWindow.h>
29 int flip(DrawingWindow &w)
31 std::cout << "[ " << w.width() << " x " << w.height() << " ]\n";
35 // int h = w.height();
37 int count = 50;//1 << 31;
39 // std::cerr << "loooooooooooooooooooooop "
40 // << y << " (" << c << ")\n";
42 for (int yy = y; yy < y + 10; yy++)
43 for (int x = 0; x < w.width(); x++)
45 if ((y += 10) >= w.height()) {
49 // std::cerr << "loooooooooooooooooooooop "
50 // << y << " (" << c << ")\n";
56 int mandel(DrawingWindow &w)
58 /* paramètres par défaut */
60 int haut = w.height();
68 int x, y; /* le pixel considéré */
69 float cr, ci; /* le complexe correspondant */
70 float zr, zi; /* pour calculer la suite */
72 float pr, pi; /* taille d'un pixel */
73 float rouge, vert, bleu;
76 pr = (Rmax - Rmin) / larg;
77 pi = (Imax - Imin) / haut;
80 for (x = 0; x < larg; x++) {
82 for (y = 0; y < haut; y++) {
86 for (i = 1; i <= maxiter; i++) {
90 /* |z| >= 2 : on sort de la boucle */
93 /* on calcule le z suivant */
97 /* on est sorti trop tôt du for(...):
98 on affiche le pixel d'un couleur en fonction
100 if (i <= maxiter / 2) {
101 /* entre rouge et vert */
102 vert = (2.0 * i) / maxiter;
105 } else if (i <= maxiter) {
106 /* entre vert et bleu */
108 bleu = (2.0 * i) / maxiter - 1.0;
110 } else /* (i > maxiter) */
111 rouge = vert = bleu = 0.0;
112 w.setColor(rouge, vert, bleu);
122 int lines(DrawingWindow &w)
125 int xmax = w.width();
126 int ymax = w.height();
128 double r = rand() / (float )RAND_MAX;
129 double g = rand() / (float )RAND_MAX;
130 double b = rand() / (float )RAND_MAX;
131 int x1 = rand() % xmax;
132 int y1 = rand() % ymax;
133 int x2 = rand() % xmax;
134 int y2 = rand() % ymax;
136 w.drawLine(x1, y1, x2, y2);
141 int main(int argc, char *argv[])
145 QApplication application(argc, argv);
147 DrawingWindow dd(lines, w, h);
149 return application.exec();
153 DrawingWindow *dw[nf + nm];
155 for (int i = 0; i < nf; ++i)
156 dw[i] = new DrawingWindow(flip, w, h);
157 for (int i = nf; i < nf + nm; ++i)
158 dw[i] = new DrawingWindow(mandel, w, h);
160 for (int i = 0; i < nf + nm; ++i)
163 return application.exec();