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
| #include <QApplication>
#include <QPixmap>
#include <QLabel>
#include <QGridLayout>
#include <QPolygon>
#include <QWidget>
#include <QRadialGradient>
#include <QPainter>
#include <QTimer>
//#include <QString>
#include <QPushButton>
#include <QtCore/qmath.h>
QPixmap cercle(qreal angle)
{ QColor bleunoir(0,0,30) ;
QColor jauneclair(250,250,0) ;
QColor rouge(100,0,0) ;
QColor bleu(0,0,100) ;
qreal xval = 0 ;
qreal fdx = 0 ;
xval = qCos((3.1416 * angle)/180) * 100 ;
fdx = qSin((3.1416 * angle)/180) * 100 ;
QRadialGradient radial1(205,205,55,100,100) ;
radial1.setColorAt(0,Qt::white) ;
radial1.setColorAt(1,bleu) ;
QRadialGradient radial2((205+xval),(205+fdx),30,(205+xval),(205+fdx)) ;
radial2.setColorAt(0,jauneclair) ;
radial2.setColorAt(1,rouge) ;
QPixmap fonhimg(410,410) ;
fonhimg.fill(bleunoir) ;
QPainter pinceo(&fonhimg) ;
pinceo.setPen(rouge) ;
pinceo.drawArc(105,105,200,200,(16 * 26 ),(-16 * angle)) ;
pinceo.setPen(Qt::black) ;
pinceo.setBrush(radial2) ;
pinceo.drawEllipse((165 + xval),(165 + fdx),80,80) ;
pinceo.setBrush(radial1) ;
pinceo.drawEllipse(155,155,100,100) ;
pinceo.end() ;
return fonhimg ;
}
void carre(int absc,int ordo,QPixmap * photo)
{ QColor jaune(250,250,0) ;
QColor rougeclair(250,0,0) ;
QRadialGradient radial((absc+15),(ordo+15),10,(absc+15),(ordo+15)) ;
radial.setColorAt(0,jaune) ;
radial.setColorAt(1,rougeclair) ;
QPolygon cetteform ;
cetteform.setPoints(8,0,10,10,0,20,0, 30,10,30,20,20,30, 10,30,0,20) ;
cetteform.translate(absc,ordo) ;
QPainter crayon(photo) ;
crayon.setBrush(radial) ;
crayon.drawPolygon(cetteform) ;
crayon.end() ;
}
int main(int argc,char ** argv)
{ qreal itr = 0 ;
QApplication app(argc,argv) ;
QColor bleunoir(0,0,30) ;
QPixmap image(cercle(0)) ;
QPixmap numeric(410,410) ;
numeric.fill(bleunoir) ;
QPushButton * bouton1 = new QPushButton("Fermer") ;
bouton1->setFixedSize(120,25) ;
QLabel * mlabel = new QLabel ;
mlabel->setPixmap(image) ;
QGridLayout * mlayout = new QGridLayout() ;
mlayout->addWidget(mlabel,0,0) ;
mlayout->addWidget(bouton1,1,0,Qt::AlignHCenter) ;
QWidget * cwidget = new QWidget ;
cwidget->setLayout(mlayout) ;
cwidget->show() ;
QTimer::singleShot(33,&app,SLOT(quit()) ) ;
app.exec() ;
for(itr = 0 ;itr <= 1080 ;itr++)
{ mlabel->clear() ;
mlabel->setPixmap(cercle(itr)) ;
mlayout->update() ;
cwidget->update() ;
QTimer::singleShot(33,&app,SLOT(quit()) ) ;
app.exec() ;
}
for(itr = 0 ;itr < 300 ;itr+= 30)
{ mlabel->clear() ;
carre((itr + 50),50,&numeric) ;
mlabel->setPixmap(numeric) ;
mlayout->update() ;
cwidget->update() ;
QTimer::singleShot(500,&app,SLOT(quit()) ) ;
app.exec() ;
}
for(itr = 0 ;itr < 300 ;itr+= 30)
{ mlabel->clear() ;
carre(350,(itr + 50),&numeric) ;
mlabel->setPixmap(numeric) ;
mlayout->update() ;
cwidget->update() ;
QTimer::singleShot(500,&app,SLOT(quit()) ) ;
app.exec() ;
}
for(itr = 0 ;itr < 300 ;itr+= 30)
{ mlabel->clear() ;
carre((350-itr),350,&numeric) ;
mlabel->setPixmap(numeric) ;
mlayout->update() ;
cwidget->update() ;
QTimer::singleShot(500,&app,SLOT(quit()) ) ;
app.exec() ;
}
for(itr = 0 ;itr < 300 ;itr+= 30)
{ mlabel->clear() ;
carre(50,(350-itr),&numeric) ;
mlabel->setPixmap(numeric) ;
mlayout->update() ;
cwidget->update() ;
QTimer::singleShot(500,&app,SLOT(quit()) ) ;
app.exec() ;
}
QObject::connect(bouton1,SIGNAL(clicked()),&app,SLOT(quit()) ) ;
cwidget->show() ;
app.exec() ;
return 0 ;
} |
Partager