Add to Favorites    Make Home Page 7267 Online  
 Language Categories  
 Our Services  

Home » C Home » Games and Graphics Home » Paint Brush in C (Project)

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Paint Brush in C (Project)
Author Sanju
Author Email santosh.news [at] gmail.com
Description This is my best program in graphics in c. Paint Brush.
Category C » Games and Graphics
Hits 375354
Code Select and Copy the Code
#include <graphics.h> #include <conio.h> #include<string.h> #include<process.h> #include <stdio.h> #include <stdlib.h> #include <dos.h> #include <math.h> /*#include <alloc.h>*/ #define MIN_X 83 #define MAX_X 629 #define MIN_Y 30 #define MAX_Y 409 #define MAX_BUTTONS 22 #define MAX_COLPAT 28 #define CLEAR 0 #define MARK_OP 8 #define CLIP_OP 10 #define TRANS_OP 11 #define ROTATE_OP 12 #define DELETE_OP 13 #define FLIP 14 #define MIRROR 15 #define LOAD_OP 16 #define SAVE_OP 17 #define SCALE_OP 18 typedef struct button_desc { int xmin,ymin,xmax,ymax; int button_no; char* desc; }button; button buttons[MAX_BUTTONS]; typedef struct color_button { int xmin,ymin,xmax,ymax; int color; int colflag; }color_but; color_but colorbuttons[28]; /*/color_but patternbuttons[16];*/ /*/ structure to mark an area */ struct { int top,left,bottom,right; }marker; int marked=0; /*/ to store whether marked or not*/ char FileName[40]="Untitled"; int saved=1;/*/to store if file has been saved or not*/ int LeftButtonPressed; int RightButtonPressed; int mousex,mousey; int prevx,prevy; int Current_Color=BLACK; /*/ to Store the current color */ int Current_Pattern=EMPTY_FILL;/*/ to store the current Pattern*/ int Current_Button=1;/*/ to store the current button pressed*/ int Prev_Button=1;/*/ to store the previous button */ void init(); void init_button(int,int,int,int,int,char*); void init_color_button(int,int,int,int,int,int); void New_ico(int x1, int y1); void Open_ico(int x1, int y1); void Save_ico(int x1, int y1); void Line_ico(int x1, int y1); void Rectangle_ico(int x1, int y1); void Circle_ico(int x1, int y1); void Ellipse_ico(int x1,int y1); void Sphere_ico(int x1, int y1); void Spiral_ico(int x1,int y1); void Brush_ico(int x1, int y1); void Erase_ico(int x1, int y1); void Alphabet_ico(int x, int y); void Mark_ico(int x1, int y1); void Clip_ico(int x1, int y1); void Translate_ico(int x, int y); void Rotate_ico(int x, int y); void Scale_ico(int x, int y); void Bucket_ico(int x,int y); void Cube_ico(int x, int y); void Del_ico(int x, int y); void color_ico(int x1, int y1, int c); void size_up_ico(int x, int y); void size_down_ico(int x, int y); void flip_ico(int x, int y); void mirror_ico(int x, int y); void draw_button_border(int ); void undraw_button_border(int no); void draw_color_button_border(int,int); void start_up(); void check_if_exit(); int check_mouse_on(int,int,int,int); int check_if_button_pressed(); int check_if_color(); int check_if_pattern(); void disp_filename(); void disp_coord(); void ShowStatus(char*); void ClearStatus(); char* readline(); void showmouse(); void hidemouse(); void wheremouse(int *, int *); int buttclicked(); void reset(); void getxy(); void startmouse(int,int); void restrictmouse(int,int,int,int); void Diagram(); void freehand(); void drawline(); void drawrectangle(); void erase(); void beep(); void drawtext(); void plotellipsepoints(int,int,int,int); void algoellipse(int,int,float,float); void algospiral(int,int,float,float); void drawellipse(); void drawspiral(); void drawcircle(); void Bucket(); void Cube(); void sphere(); void insert(int,int); void ffill(int,int,int,int); void save(); void Load(); void mirror(); void flip(); void mark(); void unmark(); void delete_p(); void translate(); void rotate(); void scale(); void clip(); /* void title(int,int,int,int); */ void main() { int i,j,gd=DETECT,gm=DETECT; initgraph(&gd,&gm,"c:\turboc2\include"); if(graphresult()) { printf(" Could not initialise graphics "); exit(0); } /* cleardevice(); setcolor(DARKGRAY); title(getmaxx()/2-180,getmaxy()/2-150,getmaxx()/2+180,getmaxy()/2+150); settextstyle(0,0,1); settextjustify(LEFT_TEXT,TOP_TEXT); setusercharsize(1,1,1,1); setcolor(WHITE); outtextxy(getmaxx()/2-150,getmaxy()/2-100,"Abhishek Dhingra's"); setcolor(DARKGRAY); outtextxy(170,285,"for DOS environment"); settextstyle(8,0,2); setusercharsize(3,2,5,1); setcolor(BLACK); for(i=0;i<=6;i++) outtextxy(getmaxx()/2-150+i,getmaxy()/2-150,"DOS Paint"); settextstyle(8,0,1); setusercharsize(1,1,1,1); setfillstyle(1,BLACK); rectangle(170,275,430,280); floodfill(175,277,BLACK); circle(429,186,5); settextstyle(2,0,4); outtextxy(427,180,"R"); settextstyle(6,0,1); outtextxy(150,355,"Version 1.0"); settextstyle(2,0,4); outtextxy(330,330,"This product is licensed to"); outtextxy(395,345,"R.V.C.E"); flushall(); getch(); flushall(); closegraph(); initgraph(&gd,&gm,"c:\turboc2\include"); if(graphresult()) { printf(" Could not initialise graphics "); exit(0); } */ reset(); start_up(); showmouse(); startmouse(300,300); disp_filename(); /*setfillstyle(SOLID_FILL,LIGHTGRAY);*/ /*bar(8,25,78,270); */ init(); undraw_button_border(Current_Button); while(1) { getxy(); disp_coord(); if(LeftButtonPressed) { if(check_if_button_pressed()>=0); else if(check_if_color()) ClearStatus(); else if(check_mouse_on(MIN_X+2,MIN_Y+2,MAX_X-2,MAX_Y-2)) { ClearStatus(); saved=0;/* file has been altered; */ Diagram(); } else check_if_exit(); } else check_if_button_pressed(); } } /* void title(int x,int y,int x1,int y1) { int pc; int i; hidemouse(); setcolor(LIGHTGRAY); for(i=y;i<=y1;i++) line(x,i,x1,i); setcolor(WHITE); for(i=0;i<=5;i++) { line(x+i,y+i,x1-i,y+i); line(x+i,y+i,x+i,y1-i); } setcolor(BLACK); line(x1,y1,x1,y); line(x1,y1,x,y1); setcolor(DARKGRAY); for(i=1;i<=5;i++) { line(x1-i,y1-i,x+i,y1-i); line(x1-i,y1-i,x1-i,y+i); } showmouse(); } */ void init() { int x1=10,y1=30,x2=44,y2=MAX_Y+28,ywidth=30,xwidth=30; int butt=0,i,j; New_ico(x1,y1); init_button(butt,x1,y1,xwidth,ywidth,"New File"); draw_button_border(butt); butt++; Line_ico(x2,y1); init_button(butt,x2,y1,xwidth,ywidth,"Line Drawing Tool"); draw_button_border(butt); butt++; y1=y1+ywidth; Rectangle_ico(x1,y1); init_button(butt,x1,y1,xwidth,ywidth,"Rectangle Drawing Tool"); draw_button_border(butt); butt++; Circle_ico(x2,y1); init_button(butt,x2,y1,xwidth,ywidth,"Circle Drawing Tool"); draw_button_border(butt); butt++; y1=y1+ywidth; Ellipse_ico(x1,y1); init_button(butt,x1,y1,xwidth,ywidth,"Ellipse Drawing Tool"); draw_button_border(butt); butt++; Spiral_ico(x2,y1); init_button(butt,x2,y1,xwidth,ywidth,"Spiral Drawing Tool"); draw_button_border(butt); butt++; y1=y1+ywidth; Brush_ico(x1,y1); init_button(butt,x1,y1,xwidth,ywidth,"Free Hand"); draw_button_border(butt); butt++; Erase_ico(x2,y1); init_button(butt,x2,y1,xwidth,ywidth,"Eraser"); draw_button_border(butt); butt++; y1=y1+ywidth; Mark_ico(x1,y1); init_button(butt,x1,y1,xwidth,ywidth,"Marking Tool"); draw_button_border(butt); butt++; Alphabet_ico(x2,y1); init_button(butt,x2,y1,xwidth,ywidth,"Text"); draw_button_border(butt); butt++; y1=y1+ywidth; Clip_ico(x1,y1); init_button(butt,x1,y1,xwidth,ywidth,"Clipping (Works with Mark)"); draw_button_border(butt); butt++; Translate_ico(x2,y1); init_button(butt,x2,y1,xwidth,ywidth,"Translate (Works with Mark)"); draw_button_border(butt); butt++; y1=y1+ywidth; Rotate_ico(x1,y1); init_button(butt,x1,y1,xwidth,ywidth,"Rotate (Works with mark)"); draw_button_border(butt); butt++; Del_ico(x2,y1); init_button(butt,x2,y1,xwidth,ywidth,"Delete (Works with mark)"); draw_button_border(butt); butt++; y1=y1+ywidth; flip_ico(x1,y1); init_button(butt,x1,y1,xwidth,ywidth,"Flip Canvas"); draw_button_border(butt); butt++; mirror_ico(x2,y1); init_button(butt,x2,y1,xwidth,ywidth,"Mirror Canvas"); draw_button_border(butt); butt++; y1=y1+ywidth; Open_ico(x1,y1); init_button(butt,x1,y1,xwidth,ywidth,"Open File"); draw_button_border(butt); butt++; Save_ico(x2,y1); init_button(butt,x2,y1,xwidth,ywidth,"Save File"); draw_button_border(butt); butt++; y1=y1+ywidth; Scale_ico(x1,y1); init_button(butt,x1,y1,xwidth,ywidth,"Scaling (Works with Mark)"); draw_button_border(butt); butt++; Bucket_ico(x2,y1); init_button(butt,x2,y1,xwidth,ywidth,"Bucket Fill"); draw_button_border(butt); butt++; y1=y1+ywidth; Sphere_ico(x1,y1); init_button(butt,x1,y1,xwidth,ywidth,"3D Ellipse Drawing Tool"); draw_button_border(butt); butt++; Cube_ico(x2,y1); init_button(butt,x2,y1,xwidth,ywidth,"Cuboid Drawing Tool"); draw_button_border(butt); butt++; butt=0; x1=MIN_X+8; y1=MAX_Y+9; xwidth=19;ywidth=15; for(i=0;i<8;i++) { init_color_button(butt,x1,y1,xwidth,ywidth,1); draw_color_button_border(butt,1); butt++; init_color_button(butt,x1,y2,xwidth,ywidth,1); draw_color_button_border(butt,1); butt++; x1=x1+xwidth; } butt=0; x1=x1+25; for(i=0;i<6;i++) { init_color_button(butt,x1,y1,xwidth,ywidth,0); draw_color_button_border(butt,0); butt++; init_color_button(butt,x1,y2,xwidth,ywidth,0); draw_color_button_border(butt,0); butt++; x1=x1+xwidth; } setfillstyle(Current_Pattern,Current_Color); bar(20,MAX_Y+7,65,MAX_Y+7+35); setcolor(BLACK); rectangle(20,MAX_Y+7,65,MAX_Y+7+35); setcolor(Current_Color); } void init_color_button(int color,int xmin,int ymin,int xwidth,int ywidth,int colflag) { int xgap=4; if (colflag) { colorbuttons[color].xmin=xmin; colorbuttons[color].xmax=xmin+xwidth-xgap; colorbuttons[color].ymin=ymin; colorbuttons[color].ymax=ymin+ywidth; colorbuttons[color].color=color; colorbuttons[color].colflag=colflag; } else { colorbuttons[color+16].xmin=xmin; colorbuttons[color+16].xmax=xmin+xwidth-xgap; colorbuttons[color+16].ymin=ymin; colorbuttons[color+16].ymax=ymin+ywidth; colorbuttons[color+16].color=color; colorbuttons[color+16].colflag=colflag; } } void init_button(int no,int xmin,int ymin,int xwidth,int ywidth,char* desc) { int ygap=4; buttons[no].xmin=xmin; buttons[no].ymin=ymin; buttons[no].xmax=xmin+xwidth; buttons[no].ymax=ymin+ywidth-ygap; buttons[no].desc=(char *) malloc(strlen(desc)+1); if(buttons[no].desc==NULL) { cleardevice(); printf(" No MEMORY "); } strcpy(buttons[no].desc,desc); } void draw_button_border(int no) { int color=getcolor(); hidemouse(); setcolor(WHITE); line(buttons[no].xmin,buttons[no].ymin,buttons[no].xmax,buttons[no].ymin); line(buttons[no].xmin,buttons[no].ymin,buttons[no].xmin,buttons[no].ymax); setcolor(DARKGRAY); line(buttons[no].xmax,buttons[no].ymax,buttons[no].xmax,buttons[no].ymin); line(buttons[no].xmax,buttons[no].ymax,buttons[no].xmin,buttons[no].ymax); setcolor(color); showmouse(); } void undraw_button_border(int no) { int color=getcolor(); hidemouse(); setcolor(DARKGRAY); line(buttons[no].xmin,buttons[no].ymin,buttons[no].xmax,buttons[no].ymin); line(buttons[no].xmin,buttons[no].ymin,buttons[no].xmin,buttons[no].ymax); setcolor(WHITE); line(buttons[no].xmax,buttons[no].ymax,buttons[no].xmax,buttons[no].ymin); line(buttons[no].xmax,buttons[no].ymax,buttons[no].xmin,buttons[no].ymax); setcolor(color); showmouse(); } void draw_color_button_border(int no,int colflag) { int color=getcolor(); setcolor(BLACK); if (colflag) { line(colorbuttons[no].xmin,colorbuttons[no].ymin,colorbuttons[no].xmax,col orbuttons[no].ymin); line(colorbuttons[no].xmin,colorbuttons[no].ymin,colorbuttons[no].xmin,col orbuttons[no].ymax); line(colorbuttons[no].xmax,colorbuttons[no].ymax,colorbuttons[no].xmax,col orbuttons[no].ymin); line(colorbuttons[no].xmax,colorbuttons[no].ymax,colorbuttons[no].xmin,col orbuttons[no].ymax); setfillstyle(1,no); floodfill(colorbuttons[no].xmin+1,colorbuttons[no].ymin+1,BLACK); } else { line(colorbuttons[no+16].xmin,colorbuttons[no+16].ymin,colorbuttons[no+16] xmax,colorbuttons[no+16].ymin); line(colorbuttons[no+16].xmin,colorbuttons[no+16].ymin,colorbuttons[no+16] xmin,colorbuttons[no+16].ymax); line(colorbuttons[no+16].xmax,colorbuttons[no+16].ymax,colorbuttons[no+16] xmax,colorbuttons[no+16].ymin); line(colorbuttons[no+16].xmax,colorbuttons[no+16].ymax,colorbuttons[no+16] xmin,colorbuttons[no+16].ymax); setfillstyle(no,LIGHTBLUE); floodfill(colorbuttons[no+16].xmin+1,colorbuttons[no+16].ymin+1,BLACK); } setcolor(color); } void New_ico(int x1, int y1) { setlinestyle(0, 1, 1); setcolor(BLACK); line(9+x1, 4+y1, 9+x1, 20+y1); line(9+x1, 20+y1, 21+x1, 20+y1); line(21+x1, 20+y1, 21+x1, 8+y1); line(9+x1, 4+y1, 17+x1, 4+y1); line(17+x1, 4+y1, 17+x1, 8+y1); line(17+x1, 8+y1, 21+x1, 8+y1); line(21+x1, 8+y1, 17+x1, 4+y1); setfillstyle(1, WHITE); floodfill(10+x1, 9+y1, BLACK); } void Open_ico(int x1, int y1) { setlinestyle(0, 1, 1); setcolor(BLACK); line(5+x1, 20+y1, 17+x1, 20+y1); line(17+x1, 20+y1, 24+x1, 15+y1); line(24+x1, 15+y1, 12+x1, 15+y1); line(12+x1, 15+y1, 5+x1, 20+y1); setfillstyle(1, DARKGRAY); floodfill(10+x1, 18+y1, BLACK); line(5+x1, 20+y1, 5+x1, 10+y1); line(5+x1, 10+y1, 6+x1, 8+y1); line(6+x1, 8+y1, 8+x1, 8+y1); line(8+x1, 8+y1, 9+x1, 10+y1); line(9+x1, 10+y1, 17+x1, 10+y1); line(17+x1, 10+y1, 17+x1, 15+y1); setfillstyle(1, YELLOW); floodfill(6+x1, 12+y1, BLACK); line(15+x1, 7+y1, 17+x1, 5+y1); line(17+x1, 5+y1, 22+x1, 7+y1); line(22+x1, 7+y1, 24+x1, 12+y1); line(24+x1, 12+y1, 20+x1, 10+y1); line(24+x1, 12+y1, 26+x1, 9+y1); } void Save_ico(int x1, int y1) { setlinestyle(0, 1, 1); setcolor(BLACK); line(6+x1, 4+y1, 24+x1, 4+y1); line(24+x1, 4+y1, 24+x1, 20+y1); line(24+x1, 20+y1, 8+x1, 20+y1); line(8+x1, 20+y1, 6+x1, 18+y1); line(6+x1, 18+y1, 6+x1, 4+y1); line(9+x1, 4+y1, 9+x1, 12+y1); line(9+x1, 12+y1, 21+x1, 12+y1); line(21+x1, 12+y1, 21+x1, 4+y1); line(10+x1, 20+y1, 10+x1, 15+y1); line(10+x1, 15+y1, 20+x1, 15+y1); line(20+x1, 15+y1, 20+x1, 20+y1); line(17+x1, 15+y1, 17+x1, 20+y1); line(21+x1, 7+y1, 24+x1, 7+y1); setfillstyle(1, WHITE); floodfill(10+x1, 5+y1, BLACK); setfillstyle(1, LIGHTBLUE); floodfill(7+x1, 5+y1, BLACK); setfillstyle(1, DARKGRAY); floodfill(11+x1, 19+y1, BLACK); } void Line_ico(int x1, int y1) { line(8+x1, 5+y1, 22+x1, 19+y1); } void Rectangle_ico(int x1, int y1) { rectangle(8+x1, 5+y1, 22+x1, 19+y1); } void Circle_ico(int x1, int y1) { circle(15+x1, 12+y1, 8); } void Spiral_ico(int x1, int y1) { int xrad=3,yrad=1; int i; x1=15+x1; y1=14+y1; for( i = 1; i <=4; ++i ) { ellipse( x1, y1, 90, 270, xrad, yrad ); xrad += 1; yrad += 1; y1 -= 1; ellipse( x1, y1, 270, 90, xrad, yrad ); xrad += 1; yrad += 1; y1 += 1; } } void Ellipse_ico(int x1,int y1) { ellipse(15+x1, 13+y1, 0, 360, 8, 6); } void Brush_ico(int x1, int y1) { setcolor(BLACK); setlinestyle(0, 1, 3); line(19+x1, 21+y1, 10+x1, 9+y1); setlinestyle(0, 1, 1); line(11+x1, 9+y1, 11+x1, 6+y1); line(11+x1, 6+y1, 6+x1, 4+y1); line(6+x1, 4+y1, 7+x1, 9+y1); line(7+x1, 9+y1, 11+x1, 9+y1); } void Fill_ico(int x1, int y1) { setlinestyle(0, 1, 1); setcolor(BLACK); line(10+x1, 11+y1, 16+x1, 19+y1); line(16+x1, 19+y1, 25+x1, 12+y1); line(25+x1, 12+y1, 20+x1, 5+y1); line(10+x1, 11+y1, 24+x1, 11+y1); setfillstyle(1, RED); floodfill( 12+x1, 12+y1, BLACK); setcolor(RED); line(10+x1, 11+y1, 8+x1, 14+y1); line(8+x1, 14+y1, 8+x1, 16+y1); } void Cube_ico(int x, int y) { rectangle(8+x, 5+y, 24+x, 17+y); rectangle(5+x, 9+y, 21+x, 21+y); line(5+x, 9+y, 8+x, 5+y); line(21+x, 21+y, 24+x, 17+y); line(21+x, 9+y, 24+x, 5+y); line(5+x, 21+y, 8+x, 17+y); } void Erase_ico(int x1, int y1) { setlinestyle(0, 1, 1); setcolor(BLACK); line(14+x1, 20+y1, 25+x1, 7+y1); line(25+x1, 7+y1, 23+x1, 4+y1); line(23+x1, 4+y1, 12+x1, 17+y1); line(12+x1, 17+y1, 14+x1, 20+y1); line(14+x1, 20+y1, 5+x1, 20+y1); line(5+x1, 20+y1, 5+x1, 17+y1); line(5+x1, 17+y1, 12+x1, 17+y1); line(5+x1, 17+y1, 16+x1, 4+y1); line(16+x1, 4+y1, 23+x1, 4+y1); setfillstyle(1, DARKGRAY); floodfill(14+x1, 18+y1, BLACK); setfillstyle(1, WHITE); floodfill(16+x1, 5+y1, BLACK); } void Alphabet_ico(int x, int y) { setcolor(BLACK); setlinestyle(0, 1, 3); line(8+x, 20+y, 18+x, 4+y); line(18+x, 4+y, 18+x, 20+y); setlinestyle(0, 1, 1); line(12+x, 14+y, 19+x, 14+y); line(6+x, 20+y, 12+x, 20+y); line(15+x, 20+y, 21+x, 20+y); } void Mark_ico(int x1, int y1) { setlinestyle(0, 1, 1); setcolor(BLACK); setlinestyle(3, 1, 1); rectangle(5+x1, 5+y1, 25+x1, 19+y1); setlinestyle(0, 1, 1); } void Clip_ico(int x1, int y1) { setlinestyle(0, 1, 1); setcolor(BLACK); rectangle(5+x1, 5+y1, 25+x1, 19+y1); setfillstyle(1, WHITE); floodfill(15+x1, 12+y1, BLACK); setfillstyle(1,BLACK); bar(12+x1, 10+y1, 23+x1, 17+y1); } void Translate_ico(int x, int y) { setcolor(BLACK); line(6+x, 3+y, 20+x, 3+y); line(20+x, 3+y, 20+x, 8+y); line(6+x, 3+y, 6+x, 16+y); line(6+x, 16+y, 12+x, 16+y); line(25+x, 8+y, 12+x, 8+y); line(12+x, 8+y, 12+x, 20+y); line(12+x, 20+y, 25+x, 20+y); line(25+x, 20+y, 25+x, 8+y); setfillstyle(1, LIGHTRED); floodfill(8+x, 5+y, BLACK); floodfill(20+x, 18+y, BLACK); } void Rotate_ico(int x, int y) { setcolor(BLACK); line(6+x, 5+y, 20+x, 5+y); line(20+x, 5+y, 20+x, 8+y); line(6+x, 5+y, 6+x, 18+y); line(6+x, 18+y, 12+x, 18+y); line(15+x, 7+y, 26+x, 11+y); line(26+x, 11+y, 21+x, 20+y); line(21+x, 20+y, 11+x, 16+y); line(11+x, 16+y, 15+x, 7+y); setfillstyle(1, LIGHTRED); floodfill(8+x, 7+y, BLACK); floodfill(20+x, 18+y, BLACK); } void Del_ico(int x, int y) { setcolor(RED); setlinestyle(0, 1, 3); line(9+x, 5+y, 16+x, 11+y); line(16+x, 11+y, 21+x, 18+y); line(20+x, 5+y, 11+x, 12+y); line(11+x, 12+y, 8+x, 19+y); setcolor(BLACK); setlinestyle(0, 1, 1); } void color_ico(int x1, int y1, int c) { setcolor(BLACK); rectangle(x1, y1, x1+9, y1+8); setfillstyle(1, c); floodfill(x1+1, y1+1, BLACK); } void size_up_ico(int x, int y) { x-=6; y-=4; setcolor(BLACK); line(x+10, y+12, x+22, y+7); line(x+22, y+7, x+34, y+12); line(x+10, y+12, x+34, y+12); setfillstyle(1, BLACK); floodfill(x+20, y+10, BLACK); } void size_down_ico(int x, int y) { x-=6; y-=3; setcolor(BLACK); line(x+10, y+7, x+22, y+12); line(x+22, y+12, x+34, y+7); line(x+10, y+7, x+34, y+7); setfillstyle(1, BLACK); putpixel(x+20, y+10, WHITE); floodfill(x+20, y+10, BLACK); } void Sphere_ico(int x1, int y1) { setlinestyle(0, 1, 1); setcolor(BLACK); circle(x1+15,y1+13,8); ellipse(x1+15,y1+13,0,360,4,8); ellipse(x1+15,y1+13,0,360,8,4); } void Bucket_ico(int x, int y) { setlinestyle(0, 1, 1); setcolor(BLACK); line(7+x, 8+y, 11+x, 20+y); line(11+x, 20+y, 21+x, 16+y); line(21+x, 16+y, 17+x, 4+y); line(7+x, 8+y, 17+x, 4+y); line(17+x, 4+y, 7+x, 8+y); line(3+x, 12+y, 7+x, 8+y); line(3+x, 12+y, 5+x, 15+y); line(5+x, 15+y, 7+x, 8+y); setfillstyle(1, BLUE); floodfill(10+x, 9+y, BLACK); setfillstyle(1, YELLOW); floodfill(5+x, 13+y, BLACK); } void flip_ico(int x, int y) { setcolor(BLACK); line(14+x, 4+y, 8+x, 8+y); line(8+x, 8+y, 12+x, 8+y); line(12+x, 8+y, 12+x, 15+y); line(12+x, 15+y, 8+x, 15+y); line(8+x, 15+y, 14+x, 19+y); line(14+x, 19+y, 20+x, 15+y); line(20+x, 15+y, 16+x, 15+y); line(16+x, 15+y, 16+x, 8+y); line(16+x, 8+y, 20+x, 8+y); line(20+x, 8+y, 14+x, 4+y); setfillstyle(1, CYAN); floodfill(14+x, 10+y, BLACK); } void mirror_ico(int x, int y) { setcolor(BLACK); line(6+x, 12+y, 10+x, 17+y); line(11+x, 18+y, 11+x, 15+y); line(11+x, 15+y, 18+x, 15+y); line(18+x, 15+y, 18+x, 18+y); line(18+x, 18+y, 23+x, 12+y); line(23+x, 12+y, 18+x, 6+y); line(18+x, 6+y, 18+x, 10+y); line(18+x, 10+y, 11+x, 10+y); line(11+x, 10+y, 11+x, 6+y); line(11+x, 6+y, 6+x, 12+y); setfillstyle(1, CYAN); floodfill(9+x, 12+y, BLACK); } void Scale_ico(int x,int y) { int i; setcolor(BLUE); line(x+5,y+5,x+5,y+20); line(x+25,y+5,x+25,y+20); setcolor(RED); for(i=y+7;i<y+19;i+=2) line(x+7,i,x+23,i); } void start_up() { setfillstyle(1, LIGHTGRAY); floodfill(200, 200, 1); /* FOR MAIN WINDOW */ setcolor(15); line(0, 0, 639, 0); line(0, 0+1, 639-1, 0+1); line(0, 0, 0, 479-1); line(0+1, 0, 0+1, 479-2); setcolor(8); line(639, 0+1, 639, 479); line(639-1, 0+2, 639-1, 479-1); line(639, 479, 0, 479); line(639, 479-1, 0+1, 479-1); /* for drawing window */ setcolor(WHITE); rectangle(MIN_X, MIN_Y, MAX_X, MAX_Y); setfillstyle(1, WHITE); floodfill(300, 300, WHITE); setcolor(8); line(MIN_X, MIN_Y, MAX_X, MIN_Y); line(MIN_X, MIN_Y+1, MAX_X-1, MIN_Y+1); line(MIN_X, MIN_Y, MIN_X, MAX_Y-1); line(MIN_X+1, MIN_Y, MIN_X+1, MAX_Y-2); setcolor(8); line(MAX_X, MIN_Y+1, MAX_X, MAX_Y); line(MAX_X-1, MIN_Y+2, MAX_X-1, MAX_Y-1); line(MAX_X, MAX_Y, MIN_X, MAX_Y); line(MAX_X, MAX_Y-1, MIN_X+1, MAX_Y-1); /* for status bar */ setcolor(8); line(10, 460, 629, 460); line(10, 460, 10, 479 - 5-1); setcolor(15); line(629, 460 , 629, 479 - 5); line(629, 479 - 5, 10, 479 - 5); /*/ For color*/ setcolor(15); line(MIN_X, MAX_Y+4, 251, MAX_Y+4); line(MIN_X, MAX_Y+4, MIN_X,MAX_Y+47); setcolor(0); line(251, MAX_Y+47 , MIN_X, MAX_Y+47); line(251, MAX_Y+47, 251, MAX_Y+4); /*/ For background */ setcolor(15); line(258, MAX_Y+4, 386, MAX_Y+4); line(258, MAX_Y+4, 258,MAX_Y+47); setcolor(0); line(386, MAX_Y+47 , 258, MAX_Y+47); line(386, MAX_Y+47, 386, MAX_Y+4); /* For Names */ setcolor(15); line(8, 365, 76,365); line(8, 365, 8,MAX_Y-10); setcolor(0); line(76, MAX_Y-10 ,8, MAX_Y-10); line(76, MAX_Y-10, 76,365); setcolor(BLUE); outtextxy(35,MAX_Y-40,"By"); outtextxy(12,MAX_Y-30,"Sanju"); /* For college */ setcolor(15); line(400, MAX_Y+4, 630, MAX_Y+4); line(400, MAX_Y+4, 400,MAX_Y+47); setcolor(0); line(630, MAX_Y+47 , 400, MAX_Y+47); line(630, MAX_Y+47, 630, MAX_Y+4); setcolor(BLUE); outtextxy(410,MAX_Y+15,"Developed At :"); outtextxy(410,MAX_Y+31,"R.V College of Engineering"); } void disp_filename() { char name[60]; int xpos; setfillstyle(SOLID_FILL,BLUE); bar(10,5,629,18); strcpy(name,"DOS Paint - "); strcat(name,FileName); xpos=(getmaxx()-textwidth(name))/2; setcolor(LIGHTRED); outtextxy(xpos,8,name); setfillstyle(SOLID_FILL,BLUE); bar(614,6,628,17); outtextxy(620,8,"X"); } void disp_coord() { char xy[25]; int color; if(prevx!=mousex||prevy!=mousey) if( (mousex>MIN_X+1)&&(mousex<MAX_X-1)&&(mousey>MIN_Y+1)&&(mousey<MAX_Y-1)) { sprintf(xy," x : %d y : %d",mousex-MIN_X-2,mousey-MIN_Y-2); color=getcolor(); setcolor(LIGHTGRAY); outtextxy(475,464,"?????????????????" );/* ALT 219*/ setcolor(BLACK); outtextxy(475,464,xy); setcolor(color); } } void reset() { union REGS regs; regs.x.ax=0; int86(0x33,®s,®s); if(regs.x.ax==0) { printf(" No Mouse Drivers "); exit(0); } } void showmouse() { union REGS regs; regs.x.ax=1; int86(0x33,®s,®s); } void hidemouse() { union REGS regs; regs.x.ax=2; int86(0x33,®s,®s); } int buttclicked() { union REGS regs; regs.x.ax=3; int86(0x33,®s,®s); return regs.x.bx; } void wheremouse(int *x,int*y) { union REGS regs; regs.x.ax=3; int86(0x33,®s,®s); *x=regs.x.cx; *y=regs.x.dx; } void getxy() { union REGS regs; regs.x.ax=3; int86(0x33,®s,®s); prevx=mousex; prevy=mousey; if(regs.x.bx&1) LeftButtonPressed=1; else LeftButtonPressed=0; if(regs.x.bx&2) RightButtonPressed=1; else RightButtonPressed=0; mousex=regs.x.cx; mousey=regs.x.dx; } void startmouse(int x,int y) { union REGS regs; regs.x.ax=4; regs.x.cx=x; regs.x.dx=y; int86(0x33,®s,®s); } void restrictmouse(int minx,int miny,int maxx,int maxy) { union REGS regs; regs.x.cx=minx; regs.x.dx=maxx; regs.x.ax=0x7; int86(0x33,®s,®s); regs.x.cx=miny; regs.x.dx=maxy; regs.x.ax=0x8; int86(0x33,®s,®s); } int check_mouse_on(int minx,int miny,int maxx,int maxy) { if(mousex<minx) return 0; if(mousex>maxx) return 0; if(mousey<miny) return 0; if(mousey>maxy) return 0; return 1; } void check_if_exit() { if( (check_mouse_on(614,6,628,17))&&LeftButtonPressed) { flushall(); closegraph(); exit(0); } } int check_if_button_pressed() { int ret_value=-1; int i; char ch; for(i=0;i<MAX_BUTTONS;++i) { if(check_mouse_on(buttons[i].xmin,buttons[i].ymin,buttons[i].xmax,buttons[ i].ymax)) { if(LeftButtonPressed && i!=Current_Button) { ret_value=i; draw_button_border(Current_Button); Prev_Button=Current_Button; undraw_button_border(i); Current_Button=i; switch(Current_Button) { case CLEAR : if(marked) unmark(); hidemouse(); if(!saved) { ShowStatus("Save Changes ? "); ch=getch(); if(ch=='y'||ch=='Y') save(); } strcpy(FileName,"Untitled"); disp_filename(); setfillstyle(SOLID_FILL,WHITE); bar(MIN_X+2,MIN_Y+2,MAX_X-2,MAX_Y-2); draw_button_border(Current_Button); undraw_button_border(Prev_Button); Current_Button=Prev_Button; setfillstyle(Current_Pattern,Current_Color); showmouse(); break; case LOAD_OP: if(marked) unmark(); hidemouse(); Load(); draw_button_border(Current_Button); undraw_button_border(Prev_Button); Current_Button=Prev_Button; setfillstyle(Current_Pattern,Current_Color); showmouse(); break; case SAVE_OP:if(marked) unmark(); hidemouse(); save(); draw_button_border(Current_Button); undraw_button_border(Prev_Button); Current_Button=Prev_Button; setfillstyle(Current_Pattern,Current_Color); showmouse(); break; case MIRROR:if(marked) unmark(); hidemouse(); mirror(); draw_button_border(Current_Button); undraw_button_border(Prev_Button); Current_Button=Prev_Button; setfillstyle(Current_Pattern,Current_Color); showmouse(); break; case FLIP: if(marked) unmark(); hidemouse(); flip(); draw_button_border(Current_Button); undraw_button_border(Prev_Button); Current_Button=Prev_Button; setfillstyle(Current_Pattern,Current_Color); showmouse(); break; case DELETE_OP: hidemouse(); delete_p(); draw_button_border(Current_Button); undraw_button_border(Prev_Button); Current_Button=Prev_Button; setfillstyle(Current_Pattern,Current_Color); showmouse(); break; case ROTATE_OP: hidemouse(); rotate(); draw_button_border(Current_Button); undraw_button_border(Prev_Button); Current_Button=Prev_Button; setfillstyle(Current_Pattern,Current_Color); showmouse(); break; case CLIP_OP: hidemouse(); clip(); draw_button_border(Current_Button); undraw_button_border(Prev_Button); Current_Button=Prev_Button; setfillstyle(Current_Pattern,Current_Color); showmouse(); break; case SCALE_OP: hidemouse(); scale(); draw_button_border(Current_Button); undraw_button_border(Prev_Button); Current_Button=Prev_Button; setfillstyle(Current_Pattern,Current_Color); showmouse(); break; } if(Current_Button!=MARK_OP&&Current_Button!=TRANS_OP) { if(marked) unmark(); } } if(prevx!=mousex||prevy!=mousey) ShowStatus(buttons[i].desc); return ret_value; } } ClearStatus(); return ret_value; } int check_if_color() { int i=0; for(i=0;i<MAX_COLPAT;i++) { if(check_mouse_on(colorbuttons[i].xmin,colorbuttons[i].ymin,colorbuttons[i ].xmax,colorbuttons[i].ymax)) { if(colorbuttons[i].colflag) { Current_Color=colorbuttons[i].color; } else Current_Pattern=colorbuttons[i].color; if (Current_Pattern==EMPTY_FILL) setfillstyle(SOLID_FILL,Current_Color); else setfillstyle(Current_Pattern,Current_Color); bar(20,MAX_Y+7,65,MAX_Y+7+35); setcolor(BLACK); rectangle(20,MAX_Y+7,65,MAX_Y+7+35); setcolor(Current_Color); return 1; } } return 0; } void ShowStatus(char* str) { int color=getcolor(); int i; ClearStatus(); setcolor(BLACK); outtextxy(12,464,str); setcolor(color); } void ClearStatus() { static int first_time; static char text[59]; int i; setcolor(LIGHTGRAY); if(!first_time) { strcpy(text,""); for(i=0;i<58;++i) strcat(text,"?"); text[58]='

Related Source Codes

Script Name Author
The Game Opposite as seen on Nokia 2300 Mobile Manikanta
RECURSIVE BALANCED QUICK SORT ashish
Radix Sort ashish
Change your mouse pointer Ashim
The blinking star Shashank
Data Validation Crylittlebaby
To search a file by giving file type like mp3 or mpeg or doc Prashanth SR
Menus Demonstration B.Chidhambaram
Employee Database Project Using C. Reenku Raman Nayak
Creating a Lexical Analyzer in c fahad bader al-buhairi ¦Õ¤ ?¤Ð Ãß??ÝÐÝ
Calendar Program Omkar & Devendra
Stop double Process for start in C Cedrik Jurak
Stop double Process for start in C Cedrik Jurak
Time Scheduler Atiq Anwar
A timepass game between atmost two players Rahul Roy

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=773


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review