-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmulticolors.cpp
58 lines (47 loc) · 1.51 KB
/
multicolors.cpp
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
#include <cmath>
#include "multicolors.h"
#include <QVBoxLayout>
#include <DTitlebar>
#include <QDebug>
#include <QObject>
#define CYELLOW Qt::yellow
#define CORANGE QColor::fromRgb(244, 67, 54)
#define CRED Qt::red
#define CPINK QColor::fromRgb(255, 80, 140)
#define CPURPLE QColor::fromRgb(156, 39, 176)
#define CCYAN QColor::fromRgb(0, 204, 175)
#define CAZURE QColor::fromRgb(0, 188, 212)
#define CBLUE Qt::blue
#define CBLACK Qt::black
#define CPEAR QColor::fromRgb(139, 195, 74)
#define CGREEN Qt::green
#define CGRAY Qt::gray
#define CWHITE Qt::white
#define CMARINBLUE QColor::fromRgb(63, 81, 181)
DWIDGET_USE_NAMESPACE
MultiColors::MultiColors(QWidget *parent) : QWidget(parent) {
}
void MultiColors::paintEvent(QPaintEvent *e)
{
// QWidget::paintEvent(e);
int timesY = (int)ceil((double)this->width() / rectangleSize);
int timesX = (int)ceil((double)this->height() / rectangleSize);
QPainter paint(this);
paint.setRenderHint(QPainter::RenderHint::Antialiasing);
QPen p;
QColor list[] = {Qt::blue, Qt::red, Qt::white, CYELLOW, CPINK, Qt::green, Qt::black, Qt::gray, Qt::yellow, Qt::cyan,
CPURPLE, CAZURE, CPEAR, CMARINBLUE, CORANGE};
int i = 0, colorC = 0;
while (i<timesX) {
int j = 0;
while (j<timesY) {
paint.fillRect(QRect(j*rectangleSize, i*rectangleSize, rectangleSize, rectangleSize), list[colorC]);
colorC++;
if (colorC>14) {
colorC = 0;
}
j++;
}
i++;
}
}