Bonjour ou bonsoir,

Voici ma contribution, une petite animation avec le mot C++, j'ai écrit ce programme sous Cinnamon Linux mint, avec un éditeur de texte, puis je l'ai compiler dans le Terminal linux.

LETTRECEY.CPP
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//Animation du mot cplusplus
 
#include <QPainter>
#include <QPixmap>
#include <QGridLayout>
#include <QWidget>
#include <QApplication>
#include <QLabel>
#include <QPoint>
#include <QTimer>
#include <QList>
#include <QPushButton>
#include <QString>
 
#include "lettrecey.h"
 
 
int main(int argc,char **argv)
{ QApplication app(argc,argv) ;
    QString mot1 = "PLAY" ;
    QString mot2 = "EXIT" ;
    QPushButton *lebouton1 = new QPushButton(mot1) ;
        lebouton1->setFixedSize(100,50) ;
    QPushButton *lebouton2 = new QPushButton(mot2) ;
        lebouton2->setFixedSize(100,50) ;
 
    QPixmap pixels(500,500) ;
        pixels.fill(Qt::white) ;
    QLabel *fenetre = new QLabel ;
        fenetre->setFixedSize(500,500) ;
 
    QGridLayout *en1fenetre = new QGridLayout ;
        en1fenetre->addWidget(fenetre,0,0,1,4) ;
        en1fenetre->addWidget(lebouton1,1,1,1,1) ;
        en1fenetre->addWidget(lebouton2,1,2,1,1) ;
 
 
    Lemotcplusplus ou ;
        pixels = ou.degraD() ;
        ou.init(fenetre, pixels) ;
 
        fenetre->setPixmap(pixels) ;
    QWidget *wfenetre = new QWidget ;
        wfenetre->setLayout(en1fenetre) ;
 
    QTimer *utemp = new QTimer ; 
        utemp->setInterval(40) ;
QObject::connect(lebouton1,SIGNAL(clicked()),utemp,SLOT(start()) );
QObject::connect(utemp,SIGNAL(timeout()),&ou,SLOT(point_par_point()) ) ;
QObject::connect( &ou,SIGNAL(dernier()),utemp,SLOT(stop()) ) ;
 
QObject::connect( lebouton2,SIGNAL(clicked()),&app,SLOT(quit()) ) ;
 
wfenetre->show() ;
 
app.exec() ;
return 0 ;
}

LETTRECEY.H
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#ifndef _LETTRECEY_H_
#define _LETTRECEY_H_
 
#include <QPainter>
#include <QPixmap>
#include <QApplication>
#include <QLabel>
#include <QPoint>
#include <QTimer>
#include <QList>
#include <QColor>
#include <QPen>
#include <QObject>
 
 
class Lemotcplusplus : public QObject
{   Q_OBJECT
 
    public :
 // Toutes les coordonnées (x,y) de la letrre c 
 // et des 2 signes plus dans une liste.
 
    QList <QPoint> cespoints()
    {   QList <int> list_x ;
        QList <int> list_y ;
 
        QPoint pw1(190,120) ;  
        QPoint pnt_ax(210,250) ; 
        QPoint pnt_ay(258,202) ; 
 
        QPoint pnt_bx(365,250) ;
        QPoint pnt_by(412,202) ;
 
        int cpt = 0 ;   
 
        for ( cpt = 190 ; cpt > 100 ; cpt-= 5)    
        {    pw1.rx()-= 5 ; 
             list_x << pw1.x() ;
             list_y << pw1.y() ;     
        }
 
        for ( cpt = 100 ; cpt > 40 ; cpt-= 5)
        {    pw1.rx()-= 5 ;
             pw1.ry()+= 5 ;
             list_x << pw1.x() ;
             list_y << pw1.y() ; 
        }             
 
        for ( cpt = 180 ; cpt < 320 ; cpt+= 5)
        {    pw1.ry()+= 5 ;
             list_x << pw1.x() ;
             list_y << pw1.y() ; 
        }              
 
        for ( cpt = 320 ; cpt < 380 ; cpt+= 5)
        {    pw1.rx() += 5 ;
             pw1.ry() += 5 ;
             list_x << pw1.x() ;
             list_y << pw1.y() ;     
        }
 
        for ( cpt = 100 ; cpt < 190 ; cpt+= 5)    
        {    pw1.rx()+= 5 ; 
             list_x << pw1.x() ;
             list_y << pw1.y() ; 
        }
 
 
        for ( cpt = 210 ; cpt < 305 ; cpt+= 5)
        {    pnt_ax.rx()+= 5 ;
             list_x << pnt_ax.x() ;
             list_y << pnt_ax.y() ;       
        }
 
        for ( cpt = 202 ; cpt < 297 ; cpt+= 5  )
        {    pnt_ay.ry()+= 5  ;
             list_x << pnt_ay.x() ;
             list_y << pnt_ay.y() ;             
        }
 
        for ( cpt = 365 ; cpt < 460 ; cpt+= 5)
        {    pnt_bx.rx()+= 5 ;
             list_x << pnt_bx.x() ;
             list_y << pnt_bx.y() ;           
        }
 
        for ( cpt = 202 ; cpt < 297 ; cpt+= 5)
        {    pnt_by.ry()+= 5 ;
             list_x << pnt_by.x() ;
             list_y << pnt_by.y() ;  
        }
 
        QList <QPoint> points ;
        int cpt2 = 0 ;
        int dim = list_x.size() ;
        QPoint tpoint ;
 
        for ( cpt2 = 0; cpt2 <= dim ; cpt2++)
        {   tpoint.setX(list_x.at(cpt2) ) ;
            tpoint.setY(list_y.at(cpt2) ) ;
            points << tpoint ;
        }
 
    return points ;
    }
   // création d''une image dégradé en bleu 500x500 pixels
    QPixmap degraD()
    { QPixmap cdpixels(500,500) ;
            cdpixels.fill(Qt::white) ;
        int c0 = 0 ;    int c1 = 0 ;
        int xp = 0 ;    int c2 = 0 ;      
 
        int yp = 0 ;    
 
        QColor bleu ;  
        QPainter pinceau(&cdpixels) ;
            for (c0 = 0 ; c0 < 500 ; c0++)    
            {   c1 = (c0/4) + 120;   
                c2 = c1 - 50 ;
                xp = c0 ;
                yp = 500- c0 ;
                bleu.setRgb(0,c2,c1) ;
                pinceau.setPen(bleu) ;
                pinceau.drawLine(0,yp,xp,500) ;
            }
            c1 =0 ; c2 =0 ;
            for (c0 = 0 ; c0 < 500 ; c0++)    
            {   c1 = 245 - c0/4 ;   
                c2 = c1 -50 ;
                xp = c0 ;
                yp = 500 -c0 ;
                bleu.setRgb(0,c2,c1) ;
                pinceau.setPen(bleu) ;
                pinceau.drawLine(xp,0,500,yp) ;
            }
        pinceau.end() ;
    return cdpixels ;
    }
 
 
    void init(QLabel *fenetre, QPixmap image)
    {   u_fenetre = fenetre ;
        u_image = image ;
        u_vari = 0 ;
    u_cpoints = cespoints() ;
    }
 
 
public slots:
    void point_par_point()
    {   QPoint unpoint(0,0) ; 
            unpoint = u_cpoints.at(u_vari)  ; 
        QPainter crayon(&u_image) ;
            crayon.setBrush(Qt::black) ; 
            crayon.drawEllipse(unpoint,25,25) ;
        crayon.end() ;
        if ( u_vari < (u_cpoints.size() -1) )
        {    u_vari++ ; }
 
        u_fenetre->setPixmap(u_image) ;
        u_fenetre->update() ;
        if(u_vari >= (u_cpoints.size() -1) )
        {   emit dernier() ; }
    }
 
signals:
    void dernier() ;
 
 
private:
    QLabel *u_fenetre ;
    int u_vari ;
    QPixmap u_image ;
    QList <QPoint> u_cpoints ;
};
 
#endif
LETTRECEY.PRO
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
######################################################################
# Automatically generated by qmake (3.1) Mon Aug 4 19:43:36 2025
######################################################################
 
TEMPLATE = app
TARGET = lettrecey
INCLUDEPATH += .
QT += widgets
 
(...)

Résultat à la fin de l'animation.
*********************************************
Nom : img_cplusplus.png
Affichages : 41
Taille : 29,1 Ko