-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
69 lines (61 loc) · 1.82 KB
/
mainwindow.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
59
60
61
62
63
64
65
66
67
68
69
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPainter>
#include "answindow.h"
#include <qmath.h>
const int GFullSize = 800;
const int GSize = GFullSize/2;
const int block = GSize/10;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->setFixedSize(800, 800);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::paintEvent(QPaintEvent *event){
QPainter painter(this);
painter.setPen(QPen(Qt::white,1,Qt::SolidLine, Qt::FlatCap));
painter.translate(GSize, GSize);
painter.scale(1,-1);
for (int x = -GSize; x <=GSize; ++x){
for (int y = -GSize; y <=GSize; ++y){
painter.drawPoint(x,y);
}
}
painter.setPen(QPen(Qt::black,1,Qt::SolidLine, Qt::FlatCap));
for(int i = -GSize; i<=GSize; ++i){
painter.drawPoint(i,0);
}
for (int i = -GSize; i<=GSize; ++i){
painter.drawPoint(0,i);
}
painter.setPen(QPen(Qt::red,3,Qt::SolidLine, Qt::FlatCap));
for (int x = -GSize; x <=GSize; ++x){
for (int y = -GSize; y <=GSize; ++y){
if ((abs(-3*y -2*x-2*block)<3)){
painter.drawPoint(x,y);
}
}
}
painter.setPen(QPen(Qt::green,3,Qt::SolidLine, Qt::FlatCap));
for (int x = -GSize; x <=GSize; ++x){
for (int y = -GSize; y <=GSize; ++y){
if (abs(x*y+block*block)<178){
painter.drawPoint(x,y);
}
}
}
painter.setPen(QPen(Qt::blue,3,Qt::SolidLine, Qt::FlatCap));
for (int x = -GSize; x<=GSize; ++x){
for(int y = -GSize; y<=GSize; ++y){
if((abs(block*exp(x*1.0/block) + 2*block - y)<1.7 && x <=0) ||(abs(block*exp(x*1.0/block) + 2*block - y)<3 && x >0) ){
painter.drawPoint(x,y);
}
}
}
}