-
Notifications
You must be signed in to change notification settings - Fork 4
/
elements.cpp
391 lines (306 loc) · 9.45 KB
/
elements.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
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
#define PI 3.14
#include<iostream>
#include<math.h>
#include<GL/glut.h>
using namespace std;
extern void setFont(void *font);
extern void drawstring(float x,float y,float z,const char *string);
extern void drawCircle(float cx, float cy, float r);
extern void drawCircle1234(float cx, float cy, float r);
extern int wh, ww, wx, wy, wx1, wy1;
void palette(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) /* to draw the COLOR PALETTE */
{
glBegin(GL_QUADS);
glVertex2f(x1, y1);
glVertex2f(x2, y2);
glVertex2f(x3, y3);
glVertex2f(x4, y4);
glEnd();
}
void Elements() {
wx=wx1;
wy=wy1;
glColor3f(0.85,0.93,1.0);//blue line
glPointSize(1);
glLineWidth(1);
glRectf(-1.0,-1.0,-0.98,1.0);
glRectf(0.98,-1.0,1.0,1.0);
glRectf(-1.0,-0.96,1.0,-1.0);
glRectf(-1.0,0.95,1.0,1.0);
setFont(GLUT_BITMAP_HELVETICA_12);//writing g-edit
glColor3f(0.0,0.0,0.0);
drawstring(-0.1,0.967,0.0,"G-Editor");
setFont(GLUT_BITMAP_HELVETICA_10);//bottom link for github
glColor3f(0.0,0.0,0.0);
drawstring(-0.97,-0.989,0.0,"For more information ask at https://github.com/Sanketwable/Graphics_Project/issues ");
glColor3f(0.90, 0.90, 0.90);//grey color for left and bottom
glRectf(-0.98, -0.96, -0.8,0.94);
glRectf(-0.8, -0.96, 0.98, -0.8);
glColor3f(0.80, 0.81, 0.80); //grey color for upper
glRectf(-0.98,0.95,0.98,0.88);
glColor3f(0.45,0.45,0.45);//black-grey line border inside editor
glRectf(-0.8,-0.8,-0.79,0.88);
glRectf(-0.8,-0.8,0.98,0.-0.79);
glColor3f(0.25,0.25,0.25);
glRectf(-0.8,0.88,0.98,0.87);
glColor3f(0.55,0.55,0.55);
glRectf(0.97,0.88,0.98,-0.80);
glColor3f(0.0,0.0,0.0);//file dit view image color help
setFont(GLUT_BITMAP_9_BY_15);
drawstring(-0.91,0.90,0.0,"FILE");
drawstring(-0.78,0.90,0.0,"EDIT");
drawstring(-0.67,0.90,0.0,"VIEW");
drawstring(-0.54,0.90,0.0,"IMAGE");
drawstring(-0.40,0.90,0.0,"COLOR");
drawstring(-0.26 ,0.90,0.0,"HELP");
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2f(-0.95,0.8); //white color to toolbar
glVertex2f(-0.95,-0.2);
glEnd();
glColor3f(0.99,0.99,0.99);
glBegin(GL_LINES);
glVertex2f(-0.82,0.8);
glVertex2f(-0.82,-0.2);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2f(-0.82,0.8);
glVertex2f(-0.95,0.8);
glEnd();
glColor3f(0.99,0.99,0.99);
glBegin(GL_LINES);
glVertex2f(-0.82,-0.2);
glVertex2f(-0.95,-0.2);
glEnd();
glColor3f(0.85, 0.85, 0.85); //box down to tools
glRectf(-0.82,-0.30,-0.95,-0.5);
glColor3f(0.24, 0.24, 0.24);
glBegin(GL_LINES);
glVertex2f(-0.95,-0.3);
glVertex2f(-0.95,-0.5);
glEnd();
glBegin(GL_LINES);
glVertex2f(-0.95,-0.3);
glVertex2f(-0.82,-0.3);
glEnd();
glColor3f(0.99, 0.99, 0.99);
glBegin(GL_LINES);
glVertex2f(-0.82,-0.3);
glVertex2f(-0.82,-0.5);
glEnd();
glBegin(GL_LINES);
glVertex2f(-0.95,-0.5);
glVertex2f(-0.82,-0.5);
glEnd();
//for colors i.e colors
glColor3f(0,0,1);
palette(-0.8,-0.87,-0.75,-0.87,-0.75,-0.82,-0.8,-0.82);//1
glColor3f(0,1,1);
palette(-0.74,-0.87,-0.69,-0.87,-0.69,-0.82,-0.74,-0.82);//2
glColor3f(1,0,1);
palette(-0.68,-0.87,-0.63,-0.87,-0.63,-0.82,-0.68,-0.82);//3
glColor3f(0.5,0.5,1);
palette(-0.62,-0.87,-0.57,-0.87,-0.57,-0.82,-0.62,-0.82);//4
glColor3f(0.5,1,0.5);
palette(-0.56,-0.87,-0.51,-0.87,-0.51,-0.82,-0.56,-0.82);//5
glColor3f(0.9,0.2,0.3);
palette(-0.50,-0.87,-0.45,-0.87,-0.45,-0.82,-0.50,-0.82);//6
glColor3f(0.4,0.4,0.4);
palette(-0.44,-0.87,-0.39,-0.87,-0.39,-0.82,-0.44,-0.82);//7
glColor3f(0,0,0);
palette(-0.38,-0.87,-0.33,-0.87,-0.33,-0.82,-0.38,-0.82);//8
glColor3f(0.5,0.5,0.5);
palette(-0.8,-0.93,-0.75,-0.93,-0.75,-0.88,-0.8,-0.88);//11
glColor3f(1,1,1);
palette(-0.74,-0.93,-0.69,-0.93,-0.69,-0.88,-0.74,-0.88);//22
glColor3f(0.4,0.6,0.8);
palette(-0.68,-0.93,-0.63,-0.93,-0.63,-0.88,-0.68,-0.88);//33
glColor3f(0.8,0.6,0.4);
palette(-0.62,-0.93,-0.57,-0.93,-0.57,-0.88,-0.62,-0.88);//44
glColor3f(1,0.5,1);
palette(-0.56,-0.93,-0.51,-0.93,-0.51,-0.88,-0.56,-0.88);//55
glColor3f(0.9,0.7,0.1);
palette(-0.50,-0.93,-0.45,-0.93,-0.45,-0.88,-0.50,-0.88);//66
glColor3f(0.6,0.2,0.9);
palette(-0.44,-0.93,-0.39,-0.93,-0.39,-0.88,-0.44,-0.88);//77
glColor3f(0.1,0.9,0.4);
palette(-0.38,-0.93,-0.33,-0.93,-0.33,-0.88,-0.38,-0.88);//8.8
glColor3f(0.85, 0.85, 0.85); //current color in color bar
glRectf(-0.85,-0.83,-0.94,-0.92);
glColor3f(0.24, 0.24, 0.24);
glBegin(GL_LINES);
glVertex2f(-0.94,-0.83);
glVertex2f(-0.94,-0.92);
glEnd();
glBegin(GL_LINES);
glVertex2f(-0.85,-0.83);
glVertex2f(-0.94,-0.83);
glEnd();
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_LINES);
glVertex2f(-0.85,-0.83);
glVertex2f(-0.85,-0.92);
glEnd();
glBegin(GL_LINES);
glVertex2f(-0.94,-0.92);
glVertex2f(-0.85,-0.92);
glEnd();
glColor3f(0.0,0.0,0.0);
palette(-0.92,-0.90,-0.87,-0.90,-0.87,-0.85,-0.92,-0.85);
//Drawing elements in tool bar eg,pen, pencil,triangle,eraser...etc
glColor3f(0.0,0.0,0.0); //line
glBegin(GL_LINES);
glVertex2f(-0.90,0.79);
glVertex2f(-0.94,0.73);
glEnd();
glBegin(GL_LINE_LOOP); //triangle
glVertex2f(-0.87,0.73);
glVertex2f(-0.83,0.73);
glVertex2f(-0.85,0.79);
glEnd();
glBegin(GL_LINE_LOOP); /* RECTANGLE OPTION */
glVertex2f(-0.94,0.70);
glVertex2f(-0.90,0.70);
glVertex2f(-0.90,0.64);
glVertex2f(-0.94,0.64);
glEnd();
glBegin(GL_TRIANGLES); /*PENCIL OPTION*/
glVertex2f(-0.87,0.64);
glVertex2f(-0.85,0.64);
glVertex2f(-0.87,0.66);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f(-0.85,0.64);
glVertex2f(-0.83,0.68);
glVertex2f(-0.85,0.70);
glVertex2f(-0.87,0.66);
glEnd();
glColor3f(1, 1, 1);
glBegin(GL_QUADS); /* ERASER*/
glVertex2f(-0.94,0.60);
glVertex2f(-0.90,0.60);
glVertex2f(-0.90,0.56);
glVertex2f(-0.94,0.56);
glEnd();
glColor3f(0.0, 0.0, 0.0);
drawCircle(-0.8534,0.5785,0.022);//draw circle in tool bar
glBegin(GL_POINTS); //draw dot-dot brush
double j=0,k=0;
for (int i=0;i<50;i++) {
j=rand()%15;
k=rand()%15;
glVertex2f(-0.937+j/400,0.485+k/400);
}
glEnd();
glColor3f(0.1, 0.7, 0.8);
glBegin(GL_QUADS); /* to draw COLOUR FILL OPTION on tool bar */
glVertex2f(-0.849,0.479);
glVertex2f(-0.8289,0.496);
glVertex2f(-0.849,0.524);
glVertex2f(-0.870,0.507);
glEnd();
glColor3f(0.9, 0.3, 1);
glPointSize(4);
glBegin(GL_POINTS);
glVertex2f(-0.871,0.50);
glEnd();
glColor3f(0.9, 0.3, 1);
glPointSize(2);
glBegin(GL_POINTS);
glVertex2f(-0.87,0.488);
glEnd();
glColor3f(0.9, 0.3, 1);
glPointSize(1);
glBegin(GL_POINTS);
glVertex2f(-0.87,0.479);
glEnd();
glPointSize(1);
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2f(-0.870,0.507);
glVertex2f(-0.84,0.52);
glEnd();
glColor3f(1,1,1);
glBegin(GL_LINES);
glVertex2f(-0.885,0.799);
glVertex2f(-0.885,0.38);
glEnd();
glColor3f(0.7,0.7,0.7);
glBegin(GL_LINES);
glVertex2f(-0.882,0.799);
glVertex2f(-0.882,0.38);
glEnd();
glColor3f(1,1,1);
glBegin(GL_LINES);
glVertex2f(-0.949,0.719);
glVertex2f(-0.82,0.719);
glEnd();
glColor3f(0.7,0.7,0.7);
glBegin(GL_LINES);
glVertex2f(-0.949,0.714);
glVertex2f(-0.82,0.714);
glEnd();
glColor3f(1,1,1);
glBegin(GL_LINES);
glVertex2f(-0.949,0.62);
glVertex2f(-0.82,0.62);
glEnd();
glColor3f(0.7,0.7,0.7);
glBegin(GL_LINES);
glVertex2f(-0.949,0.618);
glVertex2f(-0.82,0.618);
glEnd();
glColor3f(1,1,1);
glBegin(GL_LINES);
glVertex2f(-0.949,0.54);
glVertex2f(-0.82,0.54);
glEnd();
glColor3f(0.7,0.7,0.7);
glBegin(GL_LINES);
glVertex2f(-0.949,0.538);
glVertex2f(-0.82,0.538);
glEnd();
glColor3f(1,1,1);
glBegin(GL_LINES);
glVertex2f(-0.949,0.46);
glVertex2f(-0.82,0.46);
glEnd();
glColor3f(0.7,0.7,0.7);
glBegin(GL_LINES);
glVertex2f(-0.949,0.458);
glVertex2f(-0.82,0.458);
glEnd();
glColor3f(1,1,1);
glBegin(GL_LINES);
glVertex2f(-0.949,0.38);
glVertex2f(-0.82,0.38);
glEnd();
glColor3f(0.7,0.7,0.7);
glBegin(GL_LINES);
glVertex2f(-0.949,0.385);
glVertex2f(-0.82,0.385);
glEnd();
glColor3f(1,1,1);
palette(0.93,-0.82,0.81,-0.82,0.81,-0.86,0.93,-0.86);
glFlush();
glColor3f(0,0,0);
drawstring(0.83,-0.855,0.0,"Clear");
glColor3f(1,0.0,0.0);
drawstring(0.835,-0.855,0.0,"Clear");
glColor3f(1,0.1,0.1);
drawstring(0.833,-0.855,0.0,"Clear");
glFlush();
glColor3f(0,0,0);
glBegin(GL_LINE_LOOP); /* to draw multiplelines OPTION on tool bar */
glVertex2f(-0.83, 0.405);
glVertex2f(-0.87, 0.405);
glVertex2f(-0.87, 0.42);
glVertex2f(-0.85, 0.42);
glVertex2f(-0.86, 0.44);
glVertex2f(-0.84, 0.44);
glEnd();
glPointSize(4);
glColor3f(0.0,0.0,0.0);
drawCircle1234(-0.918,0.419,0.022);
}