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 void flip(DrawingWindow &w)
31 std::cout << "[ " << w.width << " x " << w.height << " ]\n";
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++)
47 if ((y += 10) >= w.height) {
51 // std::cerr << "loooooooooooooooooooooop "
52 // << y << " (" << c << ")\n";
57 void mandel(DrawingWindow &w)
59 /* paramètres par défaut */
69 int x, y; /* le pixel considéré */
70 float cr, ci; /* le complexe correspondant */
71 float zr, zi; /* pour calculer la suite */
73 float pr, pi; /* taille d'un pixel */
74 float rouge, vert, bleu;
77 pr = (Rmax - Rmin) / larg;
78 pi = (Imax - Imin) / haut;
81 for (x = 0; x < larg; x++) {
83 for (y = 0; y < haut; y++) {
87 for (i = 1; i <= maxiter; i++) {
91 /* |z| >= 2 : on sort de la boucle */
94 /* on calcule le z suivant */
98 /* on est sorti trop tôt du for(...):
99 on affiche le pixel d'un couleur en fonction
101 if (i <= maxiter / 2) {
102 /* entre rouge et vert */
103 vert = (2.0 * i) / maxiter;
106 } else if (i <= maxiter) {
107 /* entre vert et bleu */
109 bleu = (2.0 * i) / maxiter - 1.0;
111 } else /* (i > maxiter) */
112 rouge = vert = bleu = 0.0;
113 w.setColor(rouge, vert, bleu);
123 void lines(DrawingWindow &w)
129 double r = rand() / (float )RAND_MAX;
130 double g = rand() / (float )RAND_MAX;
131 double b = rand() / (float )RAND_MAX;
132 int x1 = rand() % xmax;
133 int y1 = rand() % ymax;
134 int x2 = rand() % xmax;
135 int y2 = rand() % ymax;
137 w.drawLine(x1, y1, x2, y2);
142 void rectangles(DrawingWindow &w)
145 int z = (w.width > w.height ? w.height : w.width) / 2;
148 w.drawRect(z, z, w.width - 1 - z, w.height - 1 - z);
153 int main(int argc, char *argv[])
157 QApplication application(argc, argv);
161 DrawingWindow *dw[nf + nm];
163 for (int i = 0; i < nf; ++i)
164 dw[i] = new DrawingWindow(flip, w, h);
165 for (int i = nf; i < nf + nm; ++i)
166 dw[i] = new DrawingWindow(mandel, w, h);
168 for (int i = 0; i < nf + nm; ++i)
171 DrawingWindow dr(rectangles, w, h);
174 DrawingWindow dl(lines, w, h);
177 return application.exec();