-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathShape.h
53 lines (44 loc) · 1.27 KB
/
Shape.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
#include "Pixel.h"
public class Shape{
private:
vector<Pixel> v;
public:
Shape(){}
Shape(const Shape& shp) v(shp.v.begin(),shp.v.end()){}
Shape(vector<Pixel> v)v(v.begin(),v.end()){}
Shape& translate(int tx, int ty){
for(auto& i:v) i.setPos(i.getX()+tx,i.getY()+ty);
return this;
}
Shape& setColor(Color color)
{
for(auto& i:v) i.setColor(color);
return this;
}
vector<Pixel> getPixels(){
return v;
}
static Shape getTriangle(size_t size, Color color){
vector<Pixel> pixels;
Pixel pixel(color, Point({0,0}));
pixel.push_back(pixel);
for(int i=1;i<size;i++){
pixels.push_back(pixel);
pixel.setPos(pixel.getX()+1,pixel.getY()+1);
}
while(pixel.getY()!=0){
pixel.setPos(pixel.getX()-1,pixel.getY()-1);
pixels.push_back(pixel);
}
while(pixel.getX()!=1){
pixel.setPos(pixel.getX()-1,pixel.getY());
pixels.push_back(pixel);
}
Shape shp(pixels);
return shp;
}
static Shape getCircle(size_t radius, Color color){
}
static Shape getRectangle(size_t width, size_t height, Color color){
}
};