-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathShape.cpp
More file actions
121 lines (96 loc) · 2.24 KB
/
Shape.cpp
File metadata and controls
121 lines (96 loc) · 2.24 KB
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
#include "Shape.h"
// Give default values to the static members
bool Shape::vertex_snap_on = true;
bool Shape::midpt_snap_on = true;
bool Shape::quad_snap_on = true;
bool Shape::division_snap_on = false;
double Shape::divisions_per_object = 4;
int Shape::selection_mask_dist = 3;
Shape Shape::shape_make_line(ShapePoint& a, ShapePoint& b,
unsigned char red = 0, unsigned char green = 0,
unsigned char blue = 0)
{
std::vector<ShapePoint> temp {a, b};
Shape s(temp, Shape::type::LINE);
s.set_color(red, green, blue);
return s;
}
Shape Shape::shape_make_circle(ShapePoint& center, double radius,
unsigned char red = 0, unsigned char green = 0,
unsigned char blue = 0)
{
std::vector<ShapePoint> temp {center, ShapePoint(center.x + radius, center.y)};
Shape s(temp, Shape::type::CIRCLE);
s.set_color(red, green, blue);
return s;
}
Shape Shape::shape_make_arc(ShapePoint& top_left,
ShapePoint& lower_right,
double angle,
double angle2,
unsigned char red,
unsigned char green, unsigned char blue)
{
std::vector<ShapePoint> temp {top_left, lower_right};
Shape s(temp, Shape::type::ARC);
s.angle_1 = angle;
s.angle_2 = angle2;
s.set_color(red, green, blue);
return s;
}
Shape::Shape()
{
}
Shape::Shape(std::vector<ShapePoint> &l, int shape_type)
{
this->type_flag = shape_type;
this->pts = l;
}
void Shape::set_color(unsigned char r, unsigned char g, unsigned char b)
{
this->r = r;
this->g = g;
this->b = b;
}
bool Shape::mouse_hits_mask(double mouse_x, double mouse_y)
{
switch(type_flag)
{
case Shape::type::LINE:
break;
case Shape::type::ARC:
break;
case Shape::type::CIRCLE:
break;
}
return false;
}
bool Shape::rectangle_touches(ShapePoint pt1, ShapePoint pt2)
{
switch(type_flag)
{
case Shape::type::LINE:
break;
case Shape::type::ARC:
break;
case Shape::type::CIRCLE:
break;
}
return false;
}
bool Shape::rectangle_encloses(ShapePoint pt1, ShapePoint pt2)
{
switch(type_flag)
{
case Shape::type::LINE:
break;
case Shape::type::ARC:
break;
case Shape::type::CIRCLE:
break;
}
return false;
}
Shape::~Shape()
{
}