Beruflich Dokumente
Kultur Dokumente
version 1.0
abstract: the graphics editor gives the flexibility to the user to create and
manipulate graphical objects, pictures and sophisticated 2-d objects.
certificate
date:
table of contents
INTRODUCTION...................................................................................................................
SYSTEM REQUIREMENTS...................................................................................................
FLOW CHART.......................................................................................................................
FUNCTIONS USED...............................................................................................................
ALGORITHM.........................................................................................................................
ACKNOWLEDGEMENT........................................................................................................
PHOTOS................................................................................................................................
BIBLIOGRAPHY...................................................................................................................
SOURCE CODE....................................................................................................................
introduction
the graphics editor helps you to edit pictures, 2-d objects and other graphical objects. the version of
the editor is 1.0. this editor has been built in c++ which provides graphical support. so this editor
uses c++ graphics libraries, which are dos compliant and are not windows compliant. this editor has
been built studying the functions and the layout of microsoft windows paint® but the code for the
editor is our own and genuine.
system requirements
1. main menu
2. drawing board
3. colour bar
4. tool bar
main menu:
this is a very important part of the editor as it is used to perform some general operations on the
editor like save, new, exit, usage, credits etc..
this menu has been divided into 3 parts
• file
• help
• edit
file: this menu consists of options to control the editor and the drawing board.
the menu elements are:
new:
this helps us to create a new drawing board by clear all the existing graphics on the drawing
board. due to limitations of c++ graphics, we have used the floodfill() function to clear the
screen. we use this tool to fill the editor with all the colours except white to clear all the
pictures on the editor and later fill the drawing area with white. this process turns out to be a
wonderful display of colours in a matter of few seconds.
note: it is advised to use the save and saveas options only a few time in a single run of the
editor. we find that borland c++ has problems with allocation of memory and does not
deallocate them properly. this might cause problems during the running of the editor and even
might hang the system.
open:
since a save function has been employed, we have created a function to open the files.
opening of the file can be done by typing the name of the file with it’s extension (.dat). if the
file exists, it will be displayed on the drawing board but, if it doesn’t exist, the drawing board
will remain unchanged. again here we have employed malloc() and putimage() functions.
since, saving was done by dividing the image into eight parts, putting of the image is also
done by putting the 8 parts of the file onto the drawing board.
exit:
this function is used to exit the whole editor.
help: this menu consists of tutorials for the user to use the editor. it also gives the user, a general
information about the creators of the editor.
the menu elements are:
credits:
this gives the user a general information about the creators of this editor and their contact
telephone numbers for further information about the editor.
about:
this option enables the user to know the some general information about the editor like
version, product information etc..
usage:
this is a very important part of the editor. this option enables the user to know the different
tools in the editor, their usage and their operation.
all the options of the help menu will display their contents covering the editor. so all the
pictures on the editor will be lost and a new drawing board is put up on the screen. so it is
advised to save the pictures on the drawing board before viewing the help menu.
edit: this menu consists of options to cut, copy and paste images. due to time constraints, we could
not develop this menu.
drawing board:
the drawing board is the area where the graphical operation can be performed. the white region in the
editor is the drawing board. this drawing area is surrounded by a blue coloured box so as to stop the
graphical objects from crossing the drawing area. if any operation is performed on the drawing board
in such a manner that the resulting graphical object goes beyond the drawing board, then the tool will
automatically get unselected. the numbers on the adjacent sides of the drawing board represent the
scale of the drawing board.
colour bar:
this bar provide the user with 15 colours to operate with. the left-most bar located on the editor is the
colour
bar.
the selection of colours need to be done only when asked for. however many tools in the editor do not
ask for colour selection and work on black colour by default.
tool bar:
this software can’t be called as a graphics editor if not for this bar. this can e considered to be the
most important bar in the editor. this bar contains all the necessary tool to perform graphical
operations on the drawing board. the options are:
floodfill:
this tool enables the user to fill a given region with a given colour. the user needs to click on a
point which is located within the area which needs to be filled. then he needs to select the
filling colour and finally the colour of the boundary. on doing so the filling colour will fill all
the area bordered by the boundary colour.
ellipse:
this is a function used to draw ellipses of given fixed dimensions. the ellipses are black in
colour by default. c++ provides the ellipse function, which we have implemented in this option.
line: this function enables the user to draw lines. we have used the line function which is
defined in graphic.h once the line option has been selected, the user needs to select the colour
of the line. once the colour is selected, a line is drawn when the user clicks the two ends of the
line on the drawing board.
circle:
this option is user to craw circles of fixed radius. the user needs to select the colour of the circle
and the centre of the circle. but this option cannot be used to draw arcs of given angular
dimensions. for this purpose, we have developed another option known as the arc function.
arc:
rectangle:
this option can be used to draw rectangles and squares. like line, colour selection needs to be
done. after the selection, the user needs to click the diagonal ends of the rectangle. after the
click the rectangles will be drawn.
x,y coor: this function is used to find the co-ordinates of a point on the drawing board. the co-
ordinates will be displayed just above the drawing board. we have introduced this option
considering that it will be of some use to the user. we have not used this tool in any of our
functions.
pencil:
this tool is used to give some flexibility to the user to create his own drawing. this can be used
just the way a pencil is used. like any other option, the colour selection must be done after
which the pencil can be used on the drawing board.
erase:
this function was introduced with an intention of erasing graphical objects. but due to time
constraints, we were unable to develop this option.
to make things easier, we have used the mouse facility. but the code for the mouse operation is
not ours and this code was obtained from book and net sources.
this is a very basic flowchart. this flowchart just gives an idea about the foundation of the editor. for detailed
understanding, refer to the algorithm.
algorithm
the following algorithm was used to develop the graphics editor. the editor is divided into
three separate files, along with their respective header files. the three files were
individually included in a common project file (*.prj). the header files used were:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <dos.h>
#include <fstream.h>
#include <string.h>
#include<alloc.h>
#include<stdlib.h>
#include "ed_util.h"
#include "oper.h"
the algorithm assumes the declaration and initialisation of certain variables belonging to
primary datatypes. a detailed explanation of some functions have been excluded in order
to enable the reader to quickly yet comprehensively get an intelligent insight into the
making of the project.
1. start
5. the structure() function is called and the template of the editor is created.
5.1 a rectangle is drawn to determine the outer boundary of the editor.
5.2 repeated usage of the line() function draws lines for the editor’s toolbar and
its scale.
5.3 setting the fill style to solid fill, and by repeated usage of floodfill function,
colour is injected into the various items in the tool bar.
5.4 the text on the toolbar is then entered as well as the readings on the scale
of the editor.
5.5 appropriate colours are then filled in other parts of the editor, and the title of
the editor is displayed.
5.6 colour for the color boxes in the editor is injected, and the editor’s main
menu is created using the line() function.
5.7 the editor is presented in full view.
mouse functions
9. an infinite while loop is opened, such that the program breaks from the function
only if the mouse coordinates are outside the main menu bar.
10. a switch case loop is opened where the value of a particular variable is
changed repeatedly.
10.1 case 1: this is for creating a new file
10.1.1 the entire editor workspace is completely filled by white
colour. the old geometrical shapes are erased.
11.2. case floodfill: this is used to fill a pre-determined area of the work space
with a certain colour. an indefinite while loop is begun.
11.2.1. if newbutton <- 1 and area <- 1, proceed to 11.2.2.
11.2.2. as indicated by the message on the editor, the relevant
mouse positions are to be clicked in order to choose the colour by which the
necessary area is to be floodfilled.
11.2.3. as in 11.2.2., click on the colour for the boundary.
11.2.4. the appropriate area is floodfilled with the colour
chosen.
11.2.5. repeat the above for steps until the mouse is clicked
outside the work space. on this event, break from the operations function.
11.3case ellipse: this is used to draw an ellipse and to drag it across the work
space.
11.3.1. an infinite while loop is begun. the mouse coordinates
are obtained.
11.3.2. if the mouse is clicked within the work space, an ellipse
is drawn from the point of the mouse click.
11.3.3. else continue.
11.3.4. repeat the previous 3 steps until the mouse is clicked
outside the work space.
11.4. case rectangle: this is used to draw a rectangle whose end coordinates
are obtained from the user.
11.4.1.click the mouse at the relevant positions to determine the colour
of the rectangle to be drawn.
11.6. case coordinates: this is used to find out the mouse coordinates at a
required position.
11.6.1.begin an infinite while loop.
11.6.2.as indicated by the message on the editor, click on any position
on the work space to get the coordinates of that position.
11.6.3.display the mouse coordinates at that point using the
check_area function.
11.6.4.repeat the above 2 steps until the mouse is clicked outside the
work space.
11.7. case erase: this is used to erase the region between 2 points that are
clicked on the work space.
11.7.1.as indicated by the message on the screen, click the mouse on 2
points on the work space, between which the portion of the
screen is to be erased.
11.7.2.begin an infinite while loop
11.7.3.use the getmouse() function to get the coordinates of the point
that is clicked.
11.7.4.if the mouse is clicked within the work space, draw a rectangle
between the points that are clicked.
graphics editor
_____________________________________________________________
________
11.7.5.floodfill the area enclosed by the rectangle with white colour.
11.7.6.repeat the previous 3 steps until the mouse is clicked outside the
work space.
13.end.
acknowledgement
during the course of our project titled “graphics editor”, we have had
many wonderful experiences and learning opportunities. we are
grateful to everyone who helped us in our work, and sincerely
appreciate their help.
we thank the principal of our school mrs. deepa sridhar for providing
us all appropriate facilities in the computer laboratory that was useful
in our building the editor. we thank our computer science lecturer
mrs. kavita for enabling us develop our computer and creativity skills.
we thank all the other lab teachers too.
we also thank our parents and classmates for their timely support and
encouragement. this is a project we will remember forever and we
profoundly express our gratitude to everyone who helped us during our
project.
akshay srivatsa
srikanteswara s
graphics editor
_____________________________________________________________
________
photos
bibliography
websites : www.programmerheaven.com
graphics editor
_____________________________________________________________
________
source code
oper.cpp
/*
graphics editor by
akshay and srikanteshwara
*/
#include <fstream.h>
#include <alloc.h>
#include <stdlib.h>
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <dos.h>
#include <string.h>
#include "ed_util.h"
#include "oper.h"
/**********/
int left, top,right, bottom, colour, j, k, l, c, i, a, r=50, side=50;
int button,mousex,mousey,newbutton,newmousex,newmousey;
extern int positionx,positiony;
void *ptr_menu,*ptr_save;
/*********/
//a&c are for increasing the radius of the circle and for switching between cases,respectively
// side is the length of the side of the square drawn with predefined//
//radius and r is the radius of the circle drawn by user
int main(void)
{
circle(100,i,i);
setcolor(5);
circle(j,100,j);
setcolor(green);
circle(k,k,100);
setcolor(red);
circle(100,l,l);
delay(100);
cleardevice();
setbkcolor(red);
setcolor(15);
/*********/
int style,size ;
/*********/
style=triplex_font;
size=7;
settextstyle(style, horiz_dir, size);
outtextxy(90,180,"graphics editor");
getch();
clrscr();
settextstyle(default_font,horiz_dir,1);
cleardevice();
setbkcolor(0);
structure(); // to call the template of the function//
/*********/
int x,y,button,temp=50;
/*********/
if(initmouse()==0)
{
printf("mouse support unavailable");
return(1);
}
showmouse();
while(1)
{
getmouse(&button,&mousex,&mousey);
// cout<<button<<" "<<mousex<<" "<<mousey<<" ";
// getch();
if(button==1)
{
menu(mousex,mousey);
delay(85);
}
else
continue;
}
}
edutil.cpp
/**********/
extern int left, top, colour, right, bottom, j, k, l, c, i, a, r, side;
graphics editor
_____________________________________________________________
________
extern int button,mousex,mousey,newbutton,newmousex,newmousey;
extern int positionx,positiony;
extern void *ptr_menu,*ptr_save;
/*********/
//a&c are for increasing the radius of the circle and for switching between cases,respectively
// side is the length of the side of the square drawn with predefined//
//radius and r is the radius of the circle drawn by user
unsigned initmouse()
{
_ax=0;
geninterrupt(0x33); //generate inpterrupt
return _ax;
}
void showmouse()
{
_ax=1;
geninterrupt(0x33);
}
void hidemouse()
{
_ax=2;
geninterrupt(0x33);
}
void structure()
rectangle(left,top,right,bottom);
line(100,50,100,468);
delay(30);
line(30,50,608,50); // code for the template of the editor//
delay(30);
line(30,30,608,30);
delay(30);
line(115,65,115,468);
delay(30);
line(115,65,608,65); //scale of the editor//
delay(30);
line(100,30,100,50); // these are the lines for the toolbar//
delay(30);
line(170,30,170,50);
delay(30);
line(50,50,50,468);
delay(30);
line(580,30,580,50);
delay(30);
setfillstyle(solid_fill,8);
delay(30);
floodfill(40,40,15); // to fill color for the tool bar//
delay(30);
floodfill(120,40,15);
delay(30);
floodfill(190,40,15);
delay(30);
floodfill(250,40,15);
delay(30);
floodfill(310,40,15);
delay(30);
floodfill(390,40,15);
delay(30);
floodfill(590,40,15);
delay(30);
floodfill(350,40,15);
delay(30);
outtextxy(50,38,"f");
delay(30);
outtextxy(122,38,"h");
delay(30);
outtextxy(590,38,"x");
setcolor(15);
outtextxy(58,38,"ile");
delay(30); // the characters for the rest of the name of the menu bar//
outtextxy(133,38,"elp");
delay(30);
delay(30);
setfillstyle(solid_fill,15);
floodfill(130,70,15);
graphics editor
_____________________________________________________________
________
setcolor(0);
delay(30);
outtextxy(118,68,"0");
delay(30);
outtextxy(218,68,"50"); //readings of the scale of the editor//
delay(30);
outtextxy(318,68,"100"); //along the horizontal//
delay(30);
outtextxy(418,68,"150");
delay(30);
outtextxy(518,68,"200");
delay(30);
outtextxy(118,168,"50");
delay(30);
outtextxy(118,268,"100"); //readings of the scale of the editor //
delay(30);
outtextxy(118,368,"150"); // along the verticle//
delay(30);
outtextxy(118,460,"200");
delay(30);
setcolor(12);
delay(30);
setfillstyle(solid_fill,8);
delay(30);
floodfill(110,70,15); // to fill color for the rest of the editor//
delay(30);
floodfill(90,70,15);
delay(30);
floodfill(70,20,15);
delay(30);
setfillstyle(solid_fill,8);
floodfill(250,20,15); //title for the editor/
outtextxy(10,40,"g");
outtextxy(10,60,"r");
outtextxy(10,80,"a");
outtextxy(10,100,"p");
outtextxy(10,120,"h");
outtextxy(10,140,"i");
outtextxy(10,160,"c");
outtextxy(10,180,"s");
outtextxy(10,220,"e");
outtextxy(10,240,"d");
outtextxy(10,260,"i");
outtextxy(10,280,"t");
outtextxy(10,300,"o");
outtextxy(10,320,"r");
delay(30);
setcolor(15);
floodfill(40,70,15);
setfillstyle(interleave_fill,1);
delay(30);
floodfill(40,100,15);
setfillstyle(interleave_fill,2);
delay(30);
floodfill(40,130,15);
setfillstyle(interleave_fill,3);
delay(30);
floodfill(40,150,15);
setfillstyle(interleave_fill,4);
delay(30);
floodfill(40,190,15);
setfillstyle(interleave_fill,5);
delay(30);
floodfill(40,220,15);
setfillstyle(interleave_fill,6);
delay(30);
floodfill(40,250,15);
setfillstyle(interleave_fill,7);
delay(30);
floodfill(40,270,15);
setfillstyle(interleave_fill,8);
delay(30);
floodfill(40,300,15);
setfillstyle(interleave_fill,9);
delay(30);
floodfill(40,330,15); //all these lines of code are for filling colors
in the color bar//
setfillstyle(interleave_fill,10);
delay(30);
floodfill(40,360,15);
setfillstyle(interleave_fill,11);
delay(30);
floodfill(40,390,15);
setfillstyle(interleave_fill,12);
delay(30);
floodfill(40,420,15);
setfillstyle(interleave_fill,13);
delay(30);
floodfill(40,450,15);
ellipse(75,118,0,360,22,12);
delay(30);
rectangle(65,152,85,172);
delay(30);
line(54,190,91,227);
delay(30);
arc(72,264,0,120,23);
delay(30);
circle(75,298,15);
delay(30);
rectangle(56,332,96,362);
delay(30);
outtextxy(60,341,"x,y");
delay(30);
outtextxy(64,351,"coor");
outtextxy(57,430,"erase");
line(70,375,70,395);
delay(30);
line(80,375,80,395);
delay(30);
line(70,375,80,375);
delay(30);
line(70,395,80,395);
delay(30);
setfillstyle(solid_fill,6);
floodfill(72,384,15);
line(80,395,75,405);
delay(30);
line(70,395,75,405);
size_t area_menu;
area_menu=imagesize(0,0,610,31);
ptr_menu=malloc(area_menu);
getimage(20,5,610,31,ptr_menu);
setcolor(2);
outtextxy(360,55,"(x,y):");
void unselect()
int y1=50+box*45;
int y2=y1+45;
if((mousex>=50 && mousex<=100) && (mousey>=y1 && mousey<=y2))
{
hidemouse();
line(50,y1,100,y1);
line(50,y2,100,y2);
line(50,y1,50,y2);
line(100,y1,100,y2);
showmouse();
delay(200);
operations(box);
return;
}
else
continue;
}
return;
}
void erase_drop()
{
hidemouse();
putimage(20,5,ptr_menu,copy_put);
showmouse();
return;
}
void colour_unselect()
{
setcolor(15);
line(30,50,30,470);
line(left,50,left,470);
for(int col=0;col<14;col++)
{
int y1=50+30*col;
line(30,y1,50,y1);
}
return;
}
void file_menu()
{
int i,j;
while(1)
{
getmouse(&newbutton,&newmousex,&newmousey);
if(newmousex>=20 && newmousex<=610 && newmousey>=5 && newmousey<=30 &&
newbutton==1)
{
int ch;
ch=((newmousex-30)/70)+1; /* this gives us the option chosen
*/
switch(ch)
{
case 1: delay(100);
hidemouse();
for(int tempo=15;tempo>=0;tempo--)
{ setfillstyle(solid_fill,tempo);
floodfill(200,400,1);
}
setcolor(black);
rectangle(145,80,605,465);
setfillstyle(solid_fill,white);
floodfill(150,90,black);
setcolor(1);
rectangle(145,80,605,465);
showmouse();
return;
}
name_save[j]='\0';
break;
}
erase_drop();
setcolor(0);
outtextxy(210,470,"enter the file name");
file.open(name_save,ios::binary);
size_t area_save;
for(int k=0;k<4;k++)
{
area_save=imagesize(105+(128*k),57,105+(128*(k+1)),265);
ptr_save=malloc(area_save);
getimage(105+(128*k),57,105+(128*(k+1)),265,ptr_save);
file.write((char*)ptr_save,area_save);
free(ptr_save);
}
for(int l=0;l<4;l++)
{
area_save=imagesize(105+(128*l),265,105+(128*(l+1)),469);
ptr_save=malloc(area_save);
getimage(105+(128*l),265,105+(128*(l+1)),469,ptr_save);
file.write((char*)ptr_save,area_save);
free(ptr_save);
}
setcolor(2);
file.close();
erase_drop();
outtextxy(37,15,"s a v e d");
delay(900);
setcolor(0);
outtextxy(37,15,"s a v e d");
setcolor(0);
outtextxy(210,470,"saveas mode");
return;
area_disp=imagesize(105+(128*s),57,105+(128*(s+1)),265);
ptr_save=malloc(area_disp);
file1.read((char*)ptr_save,area_disp);
putimage(105+(128*s),57,ptr_save,copy_put);
free(ptr_save);
}
for(int t=0;t<4;t++)
{
area_disp=imagesize(105+(128*l),265,105+(128*(l+1)),469);
ptr_save=malloc(area_disp);
file1.read((char*)ptr_save,area_disp);
putimage(105+(128*t),265,ptr_save,copy_put);
free(ptr_save);
}
file1.close();
erase_drop();
setcolor(0);
outtextxy(210,470,"open mode");
return;
case 5: hidemouse();
quit();
default: return;
}
}
else if(newbutton==1)
{
return;
}
}
}
void credits()
{
while(1)
{
getmouse(&newbutton,&newmousex,&newmousey);
if(newmousex>=20 && newmousex<=610 && newmousey>=5 && newmousey<=30 &&
newbutton==1)
{
int ch;
ch=((newmousex-30)/70)+1;
switch(ch)
{
case 2: setcolor(4);
hidemouse();
settextstyle(default_font,horiz_dir,1);
/******/
char x;
/******/
/*******/
char exit_1[100]="this is the graphics editor version 1.0 (beta)
developed as";
/*******/
length1= strlen(exit_1);
bullet(exit_1,length1,xa,ya);
/********/
int length2,length3,length4,length5;
/********/
int xb=50,xc=50,xd=50,xe=50,yb=150,yc=200,yd=250,ye=300;
/*********/
char exit_2[100]="a project for the xii grade by akshay and
srikanteshwara.";
/*********/
length2=strlen(exit_2);
bullet(exit_2,length2,xb,yb);
/*********/
char exit_3[100]="this software enables you to perform
elementary drawing and painting.";
/*********/
length3=strlen(exit_3);
bullet(exit_3,length3,xc,yc);
/*******/
char exit_4[100]="certain features have been disabled. we
apologize for the inconvenience.";
/*******/
length4=strlen(exit_4);
bullet(exit_4,length4,xd,yd);
/*******/
char exit_5[100]="press any key to return to the editor...";
/*******/
length5=strlen(exit_5);
bullet(exit_5,length5,xe,ye);
free(ptr_menu);
getch();
cleardevice();
setcolor(0);
closegraph();
int gdriver = detect, gmode, errorcode;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "d:\\tc\\bgi");
structure();
showmouse();
return;
case 1: setcolor(4);
hidemouse();
settextstyle(default_font,horiz_dir,1);
/******/
char x2;
/******/
/*******/
int length12,xa2=50,ya2=100;
/*******/
graphics editor
_____________________________________________________________
________
clrscr();
/*******/
char exit_12[100]="this editor is developed by akshay srivatsa
and srikanteswara s";
/*******/
length12= strlen(exit_12);
bullet(exit_12,length12,xa2,ya2);
/********/
int length22,length32,length42,length52;
/********/
int xb2=50,xc2=50,xd2=50,xe2=50,yb2=150,yc2=200,yd2=250,ye2=300;
/*********/
char exit_22[100]="students of xi std, sri kumaran children's
home-cbse.";
/*********/
length22=strlen(exit_22);
bullet(exit_22,length22,xb2,yb2);
/*********/
char exit_32[100]="they can be contacted at 6581662 and 6677370
respectively.";
/*********/
length32=strlen(exit_32);
bullet(exit_32,length32,xc2,yc2);
/*******/
char exit_42[100]="thank you for using graphics editor version
1.0";
/*******/
length42=strlen(exit_42);
bullet(exit_42,length42,xd2,yd2);
/*******/
char exit_52[100]="press any key to return to the editor...";
/*******/
length52=strlen(exit_52);
bullet(exit_52,length52,xe2,ye2);
free(ptr_menu);
getch();
cleardevice();
setcolor(0);
closegraph();
int gdriver2 = detect, gmode2, errorcode2;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "d:\\tc\\bgi");
structure();
showmouse();
return;
default: return;
}
}
else if(newbutton==1)
return;
}
}
outtextxy(space,y,outstr);
delay(20);
}
}
void quit()
graphics editor
_____________________________________________________________
________
{
setcolor(4);
settextstyle(default_font,horiz_dir,1);
/******/
char x;
/******/
/*******/
int length1,xa=50,ya=100;
/*******/
clrscr();
/*******/
char exit_1[100]="this editor is developed by akshay srivatsa and srikanteswara s";
/*******/
length1= strlen(exit_1);
bullet(exit_1,length1,xa,ya);
/********/
int length2,length3,length4,length5;
/********/
int xb=50,xc=50,xd=50,xe=50,yb=150,yc=200,yd=250,ye=300;
/*********/
char exit_2[100]="students of xi std, sri kumaran children's home-cbse.";
/*********/
length2=strlen(exit_2);
bullet(exit_2,length2,xb,yb);
/*********/
char exit_3[100]="they can be contacted at 6581662 and 6677370 respectively.";
/*********/
length3=strlen(exit_3);
bullet(exit_3,length3,xc,yc);
/*******/
char exit_4[100]="thank you for using graphics editor version 1.0";
/*******/
length4=strlen(exit_4);
bullet(exit_4,length4,xd,yd);
/*******/
char exit_5[100]="press any key to return to the c++ compiler...";
/*******/
length5=strlen(exit_5);
bullet(exit_5,length5,xe,ye);
free(ptr_menu);
getch();
exit(0); //quit the editor
}
oper.cpp
/* codes
0 to 14 in colours represent the 14 colours in the editor from
top to bottom
/**********/
extern int left, top, colour, right, bottom, j, k, l, c, i, a, r, side;
extern int button,mousex,mousey,newbutton,newmousex,newmousey;
int positionx,positiony;
int colour_chosen;
/**********/
/* these are variables for getmouse function same as int ed_util.cpp */
/* this function checks if the mouse pointer is within the work board */
{
if((mousex>=150 && mousex<=605) && (mousey>=65 && mousey<=470))
return(1); /* 1 represents within the board */
else
return(0); /* 0 represents outside the board */
}
/* case floodfill */
else if(item==0)
{
while(1)
{
getmouse(&newbutton,&newmousex,&newmousey);
area=check_area(newmousex,newmousey);
if(newbutton==1 && area==1)
{
positionx=newmousex;
positiony=newmousey;
setcolor(2);
outtextxy(210,470,"press the colour which needs to be filled
");
click_mouse();
colour_chosen=colour_select(newmousex,newmousey);
if(colour_chosen>=0 && colour_chosen<=14)
{
setfillstyle(solid_fill,colour_chosen);
}
else
{
unselect();
colour_unselect();
setcolor(0);
outtextxy(210,470,"press the colour which needs to be
else
{
unselect();
colour_unselect();
setcolor(0);
outtextxy(210,470,"press the colour of the boundary");
return;
}
setcolor(0);
outtextxy(210,470,"press the colour of the boundary");
colour_unselect();
continue;
}
else if(newbutton==1 && area==0)
{
unselect();
return;
}
else
continue;
}
}
/* case ellipse */
else if(item==1)
{
while(1)
{
getmouse(&newbutton,&newmousex,&newmousey);
area=check_area(newmousex,newmousey);
area=check_area(newmousex-100,newmousey-75);
if(newbutton==1 && area==1)
{
positionx=newmousex;
positiony=newmousey;
setcolor(0);
ellipse(positionx,positiony,0,360,100,50);
continue;
}
else
continue;
}
}
/* case rectangle */
if (item==2)
graphics editor
_____________________________________________________________
________
{
int positionx1,positiony1,positionx2,positiony2;
setcolor(2);
outtextxy(210,470,"click the colour of the rectangle");
click_mouse();
colour_chosen=colour_select(newmousex,newmousey);
if(colour_chosen>=0 && colour_chosen<=14)
{
setcolor(0);
outtextxy(210,470,"click the colour of the rectangle");
setcolor(2);
}
else
{
unselect();
colour_unselect();
setcolor(0);
outtextxy(210,470,"click the colour of the square");
return;
}
while(1)
{
setcolor(2);
outtextxy(210,470,"click the two ends of the rectangle");
delay(100);
click_mouse();
area=check_area(newmousex,newmousey);
if(newbutton==1 && area==1)
{
positionx1=newmousex;
positiony1=newmousey;
click_mouse();
area=check_area(newmousex,newmousey);
if(area==1)
{
positionx2=newmousex;
positiony2=newmousey;
setcolor(0);
outtextxy(210,470,"click the two ends of the rectangle");
}
else
{
unselect();
setcolor(0);
outtextxy(210,470,"click the two ends of the rectangle");
return;
}
setcolor(2);
outtextxy(210,470,"click the mouse away from area of the
rectangle");
click_mouse();
setcolor(0);
outtextxy(210,470,"click the mouse away from area of the
rectangle");
setcolor(colour_chosen);
rectangle(positionx1,positiony1,positionx2,positiony2);
continue;
}
if(newbutton==1 && area==0)
{
/* to quit lines */ unselect();
colour_unselect();
setcolor(0);
outtextxy(210,470,"click the two ends of the rectangle");
return;
}
else
continue;
}
/* case pencil */
if(item==7)
{
setcolor(2);
outtextxy(210,470,"click the colour of the pencil lead");
delay(100);
click_mouse();
colour_chosen=colour_select(newmousex,newmousey);
if(colour_chosen>=0 && colour_chosen<=14)
{
setcolor(0);
outtextxy(210,470,"click the colour of the pencil lead");
}
delay(100);
while(1)
{
setcolor(colour_chosen);
getmouse(&newbutton,&newmousex,&newmousey);
area=check_area(newmousex,newmousey);
if(newbutton==1 && area==1)
{
hidemouse();
circle(newmousex,newmousey,2);
showmouse();
}
if(newbutton==1 && area==0)
{
/* to quit lines */ unselect();
colour_unselect();
setcolor(0);
outtextxy(210,470,"click the colour of the pencil lead");
return;
}
else
continue;
}
}
/* case coor */
if(item==6)
{
setcolor(2);
outtextxy(210,470,"click the mouse within the area to get the coordinate");
while(1)
{
getmouse(&newbutton,&newmousex,&newmousey);
area=check_area(newmousex,newmousey);
if(area==1 && newbutton==1)
{
erase_drop();
outtextxy(37,15,"co-or near the drawing area: ");
gotoxy(45,5);
cout<<newmousex<<","<<newmousey;
setfillstyle(solid_fill,white);
floodfill(375,74,black);
delay(1500);
erase_drop();
}
if(area==0 && newbutton==1)
{
unselect();
colour_unselect();
setcolor(0);
outtextxy(210,470,"click the mouse within the area to get the
coordinate");
return;
graphics editor
_____________________________________________________________
________
}
}
return;
}
/* case circle */
/* case erase */
if(item==8)
{
setcolor(2);
outtextxy(210,470,"sorry,this option is not in operation.");
delay(1000);
setcolor(black);
outtextxy(210,470,"sorry,this option is not in operation.");
unselect();
return;
/* int x1,y1,x2,y2;
while(1)
{
getmouse(&newbutton,&newmousex,&newmousey);
area=check_area(newmousex,newmousey);
if(area==1 && newbutton==1)
{
x1=newmousex;
y1=newmousey;
delay(150);
while(1)
{
getmouse(&newbutton,&newmousex,&newmousey);
area=check_area(newmousex,newmousey);
if(area==1 && newbutton==1)
{
x2=newmousex;
y2=newmousey;
setcolor(2);
rectangle(x1,y1,x2,y1);
setfillstyle(solid_fill,black);
floodfill(x1+20,y1+10,black);
setfillstyle(solid_fill,white);
floodfill(x1+10,y1+10,black);
delay(150);
break;
}
if(area==0 && newbutton==1)
{
unselect();
setcolor(0);
outtextxy(210,470,"click the 2 co-ordinates");
return;
}
}
}
if(area==0 && newbutton==1)
{
unselect();
setcolor(0);
outtextxy(210,470,"click the 2 co-ordinates");
return;
}
}*/
}
} /*~1*/