-
Notifications
You must be signed in to change notification settings - Fork 0
/
Shapes.pde
168 lines (136 loc) · 1.93 KB
/
Shapes.pde
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
public class Shape {
color c;
public Shape() {
sendToOldArray();
}
}
// creating rectangle function
public class Rectangle extends Shape {
int x;
int y;
int w;
int h;
public Rectangle(int x1, int y1, int w1, int h1, color c1) {
x = x1;
y = y1;
w = w1;
h = h1;
c = c1;
}
int getX() {
return x;
}
int getY() {
return y;
}
int getW() {
return w;
}
int getH() {
return h;
}
void draw() {
fill(c);
rect(x, y, w, h);
}
}
//creating circle function
public class Ellipse extends Shape {
int x;
int y;
int w;
int h;
public Ellipse(int x1, int y1, int w1, int h1, color c1) {
x = x1;
y = y1;
w = w1;
h = h1;
c = c1;
}
int getX() {
return x;
}
int getY() {
return y;
}
int getW() {
return w;
}
int getH() {
return h;
}
void draw() {
fill(c);
ellipse(x, y, w, h);
}
}
//creating line function
public class Line extends Shape {
int x1;
int y1;
int x2;
int y2;
public Line(int nx1, int ny1, int nx2, int ny2, color c1) {
x1 = nx1;
y1 = ny1;
x2 = nx2;
y2 = ny2;
c = c1;
}
int getX1() {
return x1;
}
int getY1() {
return y1;
}
int getX2() {
return x2;
}
int getY2() {
return y2;
}
void draw() {
stroke(c);
line(x1, y1, x2, y2);
}
}
//creating triangle function
public class Triangle extends Shape {
int x;
int y;
int xx;
int yy;
int xxx;
int yyy;
public Triangle(int x1, int y1, int x2, int y2, int x3, int y3, color c1) {
x = x1;
y = y1;
xx = x2;
yy = y2;
xxx = x3;
yyy = y3;
c = c1;
}
int getX() {
return x;
}
int getY() {
return y;
}
int getXX() {
return xx;
}
int getYY() {
return yy;
}
int getXXX() {
return xxx;
}
int getYYY() {
return yyy;
}
void draw() {
fill(c);
triangle(x, y, xx, yy, xxx, yyy);
}
}