-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.h
93 lines (78 loc) · 1.54 KB
/
Main.h
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
#ifndef MAIN_H_INCLUDED
#define MAIN_H_INCLUDED
#include<bits/stdc++.h>
#define INF 10000
using namespace std;
int counter_x = 0;
int counter_y = 0;
int toggle_x = 0;
int toggle_y = 0;
int FILL_COLOR=BROWN;
int increament = 4;
const int WINDOW_W = 1500, WINDOW_H = 700;
struct PT
{
double x, y;
PT() {}
PT(double a, double b)
{
x = a;
y = b;
}
bool operator < (const PT &p)const
{
return x < p.x;
}
};
vector<pair<PT,int>>tran,circle_tran;
vector<PT>polyg;
PT prvs_circle = PT(-600,-200);
PT prvs_txt = PT(160,560);
char prvs_str[] = "L";
struct EDGE
{
double y_min, y_max,x_with_y_min,m_inv;
EDGE() {}
EDGE(double a, double b, double c, double d)
{
y_min = a;
y_max = b;
x_with_y_min = c;
m_inv = d;
}
bool operator < (const EDGE &p)const
{
return y_min < p.y_min;
}
};
void drawAxis()
{
for(int i=0; i<WINDOW_H; i++) putpixel(WINDOW_W/2, i, WHITE);
for(int i=0; i<WINDOW_W; i++) putpixel(i, WINDOW_H/2, WHITE);
}
PT convertPixel(PT p)
{
p.x += WINDOW_W/2;
p.y = -p.y;
p.y += WINDOW_H/2;
return p;
}
void drawPixel(PT p, int color,int fromWhere=0)
{
if(fromWhere==0)
{
tran.push_back({p,color});
polyg.push_back(p);
}
else if(fromWhere==2)
{
tran.push_back({p,color});
}
else if(fromWhere==3)
{
circle_tran.push_back({p,color});
}
p = convertPixel(p);
putpixel((int)(p.x+0.5), (int)(p.y+0.5), color);
}
#endif // MAIN_H_INCLUDED