Материал: Отчёт

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам

free(buffer);

}

if(ch == 'o') ///clear screan

{

setfillstyle(1, 15);

bar(3, 27, 598, 508);

}

while(!ismouseclick(WM_LBUTTONDOWN))

{

delay(100);

}

getmouseclick(WM_LBUTTONDOWN,x,y);

if(!ismouseclick(WM_LBUTTONDOWN))

{

if(x>529 && x<700 && y>40 && y<500) ch=another_shape(x,y);

if(ch=='p') ///pen

{

if(x>0 && x<528 && y>510 && y<540)active_collor(x,y);

while(!ismouseclick(WM_LBUTTONDOWN)) {}

getmouseclick(WM_LBUTTONDOWN,x,y);

int flag=1;

int tsize2=5;

do

{

getmouseclick(WM_MOUSEMOVE,x,y);

setfillstyle(1, act_col);

setlinestyle(0,1,tsize2);

if(x>2 && x<590 && y>26 && y<500)

bar(x, y, x+tsize2, y+tsize2);

flag=(ismouseclick(WM_LBUTTONDOWN));

getmouseclick(WM_LBUTTONUP, x, y);

if(x>0 && x<528 && y>510 && y<540)active_collor(x,y);

returnn();

}

while(!flag);

}

if(ch=='f') ///fill

{

if(x>0 && x<528 && y>510 && y<540)active_collor(x,y);

if(x>2 && x<590 && y>26 && y<500)

{

ismouseclick(WM_LBUTTONDOWN);

setfillstyle(1, act_col);

floodfill(x,y, 0);

}

}

if(ch=='y') ///eraser

{

while(!ismouseclick(WM_LBUTTONDOWN)) {}

getmouseclick(WM_LBUTTONDOWN,x,y);

int flag=1;

do

{

getmouseclick(WM_MOUSEMOVE,x,y);

setfillstyle(1, 15);

if(x>2 && x<580 && y>26 && y<493)

bar(x, y, x+16, y+16);

flag=(ismouseclick(WM_LBUTTONDOWN));

returnn();

}

while(!flag);

}

if(ch=='g') ///color picker

{

if(x>3 && x<596 && y>27 && y<508)

{

act_col=getpixel(x,y);

setfillstyle(1,act_col);

bar(635,515,690,535);

}

if(x>0 && x<510 && y>700 && y<540)

{

act_col=getpixel(x,y);

setfillstyle(1,act_col);

bar(635,515,690,535);

}

}

if ( ch == 'r' ) ///rectangle

{

while(ch=='r')

{

while(!ismouseclick(WM_LBUTTONDOWN)) {}

getmouseclick(WM_LBUTTONDOWN, x, y);

a=x,b=y;

delay(600);

getmouseclick(WM_LBUTTONUP, x, y);

setcolor(act_col);

setlinestyle(0,1,tsize);

if(x>2 && x<590 && y>26 && y<500)

{

rectangle(a,b,x,y);

}

if(x>0 && x<528 && y>510 && y<540)active_collor(x,y);

returnn();

}

}

if ( ch == 'b' ) ///bar

{

while(ch=='b')

{

while(!ismouseclick(WM_LBUTTONDOWN)) {}

getmouseclick(WM_LBUTTONDOWN, x, y);

a=x,b=y;

delay(700);

getmouseclick(WM_LBUTTONUP, x, y);

setfillstyle(1,act_col);

if(x>2 && x<590 && y>26 && y<500)

{

bar(a,b,x,y);

}

if(x>0 && x<528 && y>510 && y<540)active_collor(x,y);

returnn();

}

}

if ( ch == 'k') ///ellipse

{

while(ch=='k')

{

while(!ismouseclick(WM_LBUTTONDOWN)) {}

getmouseclick(WM_LBUTTONDOWN,x,y);

delay(700);

getmouseclick(WM_LBUTTONUP,coord1,coord2);

setlinestyle(0,0,tsize);

setcolor(act_col);

if(x>2 && x<590 && y>26 && y<500 && coord1>2 && coord1<590 && coord2>26 && coord2<500)

ellipse((x+coord1)/2,(y+coord2)/2,0,360,abs(x-coord1)/2,abs(y-coord2)/2);

if(x>0 && x<528 && y>510 && y<540)active_collor(x,y);

returnn();

}

}

if( ch == 'j') ///filled ellipse

{

while(ch=='j')

{

while(!ismouseclick(WM_LBUTTONDOWN)) {}

getmouseclick(WM_LBUTTONDOWN,x,y);

delay(600);

getmouseclick(WM_LBUTTONUP,coord1,coord2);

setcolor(act_col);

if(x>2 && x<590 && y>26 && y<500 && coord1>2 && coord1<590 && coord2>26 && coord2<500)

{

fillellipse((x+coord1)/2,(y+coord2)/2,abs(x-coord1)/2,abs(y-coord2)/2);

}

if(x>0 && x<528 && y>510 && y<540)active_collor(x,y);

returnn();

}

}

if(ch == 'c') ///circle

{

while(ch=='c')

{tsize=3;

while(!ismouseclick(WM_LBUTTONDOWN)) {}

getmouseclick(WM_LBUTTONDOWN,x,y);

delay(600);

getmouseclick(WM_LBUTTONUP,coord1,coord2);

int sqr=sqrt((coord1-x)*(coord1-x)+(coord2-y)*(coord2-y));

if(x>2 && x<590 && y>26 && y<500 && coord1>2 && coord1<590 && coord2>26 && coord2<50)

setlinestyle(0,0,tsize);

setcolor(act_col);

circle((coord1+x)/2,(coord2+y)/2,sqr/2);

if(x>0 && x<528 && y>510 && y<540)active_collor(x,y);

returnn();

}

}

if ( ch == '3' ) ///bar3d

{

while(ch=='3')

{

while(!ismouseclick(WM_LBUTTONDOWN)) {}

getmouseclick(WM_LBUTTONDOWN, x, y);

a=x,b=y;

delay(800);

getmouseclick(WM_LBUTTONUP, x, y);

if(x>0 && x<528 && y>510 && y<540)active_collor(x,y);

setcolor(act_col);

setlinestyle(0,1,tsize);

if(x>2 && x<590 && y>26 && y<500 && a>2 && a<590 && b>26 && b<500)

bar3d(a,b,x,y,20,1);

returnn();

}

}

if(ch=='l') /// line

{

while(ch=='l')

{

while(!ismouseclick(WM_LBUTTONDOWN)) {}

getmouseclick(WM_LBUTTONDOWN, x, y);

a=x,b=y;

delay(900);

getmouseclick(WM_LBUTTONUP, x, y);

if(x>0 && x<528 && y>510 && y<540)active_collor(x,y);

setcolor(act_col);

setlinestyle(0,1,tsize);

if(a>2 && a<590 && b>26 && b<500 && x>2 && x<590 && y>26 && y<500)

line(a,b,x,y);

returnn();

getmouseclick(WM_LBUTTONDOWN, x,y);

}

}

}

}

while(ch!='e');

}

char another_shape(int x, int y)

{

if(x>604 && x<647 && y>83 && y<127) ///pen

{

button(604, 83, 647, 127, 10);

button(652, 83, 695, 127, 15); //f

button(604, 134, 647,180, 15); //y eras

button(608, 214, 647, 243, 7); //r

button(650, 214, 691, 243, 7); //b

button(608, 245, 647, 277, 7); //k ellip

button(650, 245, 691, 277, 7); //j f ellip

button(608, 279, 647, 310, 7); //c

button(650, 279, 691, 310, 7); //3d

button(608, 312, 647, 340,7); //l

button(633, 448, 692, 497, 15); //0

button(652, 134, 695,180, 15); //g

return 'p';

}

if(x>652 && x<695 && y>83 && y<127) ///fill

{

button(652, 83, 695, 127, 10);

button(604, 83, 647, 127, 15);

button(604, 134, 647,180, 15); //y eras

button(608, 214, 647, 243, 7); //r

button(650, 214, 691, 243, 7); //b

button(608, 245, 647, 277, 7); //k ellip

button(650, 245, 691, 277, 7); //j f ellip

button(608, 279, 647, 310, 7); //c

button(650, 279, 691, 310, 7); //3d

button(608, 312, 647, 340,7); //l

button(633, 448, 692, 497, 15); //0

button(652, 134, 695,180, 15); //g

return 'f';

}

if(x>604 && x<647 && y>134 && y<180) ///eraser

{

button(604, 134, 647,180, 10);

button(604, 83, 647, 127, 15);

button(652, 83, 695, 127, 15); //f

button(608, 214, 647, 243, 7); //r

button(650, 214, 691, 243, 7); //b

button(608, 245, 647, 277, 7); //k ellip

button(650, 245, 691, 277, 7); //j f ellip

button(608, 279, 647, 310, 7); //c

button(650, 279, 691, 310, 7); //3d

button(608, 312, 647, 340,7); //l

button(633, 448, 692, 497, 15); //0

button(652, 134, 695,180, 15); //g

return 'y';

}

if(x>608 && x<647 && y>214 && y<243) ///rectangle

{

button(608, 214, 647, 243, 5);

button(604, 83, 647, 127, 15);

button(652, 83, 695, 127, 15); //f

button(604, 134, 647,180, 15); //y eras

button(650, 214, 691, 243, 7); //b

button(608, 245, 647, 277, 7); //k ellip

button(650, 245, 691, 277, 7); //j f ellip

button(608, 279, 647, 310, 7); //c

button(650, 279, 691, 310, 7); //3d

button(608, 312, 647, 340,7); //l

button(633, 448, 692, 497, 15); //0

button(652, 134, 695,180, 15); //g

return 'r';

}

if(x>650 && x<691 && y>214 && y<243) ///bar

{

button(650, 214, 691, 243, 5);

button(604, 83, 647, 127, 15);

button(652, 83, 695, 127, 15); //f

button(604, 134, 647,180, 15); //y eras

button(608, 214, 647, 243, 7); //r

button(608, 245, 647, 277, 7); //k ellip

button(650, 245, 691, 277, 7); //j f ellip

button(608, 279, 647, 310, 7); //c

button(650, 279, 691, 310, 7); //3d

button(608, 312, 647, 340,7); //l

button(633, 448, 692, 497, 15); //0

button(652, 134, 695,180, 15); //g

return 'b';

}

if(x>608 && x<647 && y>245 && y<277) /// ellipse

{

button(608, 245, 647, 277, 5);

button(604, 83, 647, 127, 15);

button(652, 83, 695, 127, 15); //f

button(604, 134, 647,180, 15); //y eras

button(608, 214, 647, 243, 7); //r

button(650, 214, 691, 243, 7); //b

button(650, 245, 691, 277, 7); //j f ellip

button(608, 279, 647, 310, 7); //c

button(650, 279, 691, 310, 7); //3d

button(608, 312, 647, 340,7); //l

button(633, 448, 692, 497, 15); //0

button(652, 134, 695,180, 15); //g

return 'k';

}

if(x>650 && x<691 && y>245 && y<277) ///filled ellipse

{

button(650, 245, 691, 277, 5);

button(604, 83, 647, 127, 15);

button(652, 83, 695, 127, 15); //f

button(604, 134, 647,180, 15); //y eras

button(608, 214, 647, 243, 7); //r

button(650, 214, 691, 243, 7); //b

button(608, 245, 647, 277, 7); //k ellip

button(608, 279, 647, 310, 7); //c

button(650, 279, 691, 310, 7); //3d

button(608, 312, 647, 340,7); //l

button(633, 448, 692, 497, 15); //0

button(652, 134, 695,180, 15); //g

return 'j';

}

if(x>608 && x<647 && y>279 && y<310) ///circle

{

button(608, 279, 647, 310, 5);

button(604, 83, 647, 127, 15);

button(652, 83, 695, 127, 15); //f

button(604, 134, 647,180, 15); //y eras

button(608, 214, 647, 243, 7); //r

button(650, 214, 691, 243, 7); //b

button(608, 245, 647, 277, 7); //k ellip

button(650, 245, 691, 277, 7); //j f ellip

button(650, 279, 691, 310, 7); //3d

button(608, 312, 647, 340,7); //l

button(633, 448, 692, 497, 15); //0

button(652, 134, 695,180, 15); //g

return 'c';

}

if(x>650 && x<691 && y>279 && y<310) ///bar3d

{

button(650, 279, 691, 310, 5);

button(604, 83, 647, 127, 15);

button(652, 83, 695, 127, 15); //f

button(604, 134, 647,180, 15); //y eras

button(608, 214, 647, 243, 7); //r

button(650, 214, 691, 243, 7); //b

button(608, 245, 647, 277, 7); //k ellip

button(650, 245, 691, 277, 7); //j f ellip

button(608, 279, 647, 310, 7); //c

button(608, 312, 647, 340,7); //l

button(633, 448, 692, 497, 15); //0

button(652, 134, 695,180, 15); //g

return '3';

}

if(x>608 && x<647 && y>312 && y<340) ///line

{

button(608, 312, 647, 340, 5);

button(604, 83, 647, 127, 15);

button(652, 83, 695, 127, 15); //f

button(604, 134, 647,180, 15); //y eras

button(608, 214, 647, 243, 7); //r

button(650, 214, 691, 243, 7); //b

button(608, 245, 647, 277, 7); //k ellip

button(650, 245, 691, 277, 7); //j f ellip

button(608, 279, 647, 310, 7); //c

button(650, 279, 691, 310, 7); //3d

button(633, 448, 692, 497, 15); //0

button(652, 134, 695,180, 15); //g

return 'l';

}

if(x>633 && x<692 && y>448 && y<497) ///clear screen

{

button(633, 448, 692, 497, 10);

button(604, 83, 647, 127, 15);

button(652, 83, 695, 127, 15); //f

button(604, 134, 647,180, 15); //y eras

button(608, 214, 647, 243, 7); //r

button(650, 214, 691, 243, 7); //b

button(608, 245, 647, 277, 7); //k ellip

button(650, 245, 691, 277, 7); //j f ellip

button(608, 279, 647, 310, 7); //c

button(650, 279, 691, 310, 7); //3d

button(608, 312, 647, 340,7); //l

button(652, 134, 695,180, 15); //g

return 'o';

}

if(x>652 && x<695 && y>134 && y<180) ///color picker

{

button(652, 134, 695,180, 10);

button(633, 448, 692, 497, 15); //o

button(604, 83, 647, 127, 15);

button(652, 83, 695, 127, 15); //f

button(604, 134, 647,180, 15); //y eras

button(608, 214, 647, 243, 7); //r

button(650, 214, 691, 243, 7); //b

button(608, 245, 647, 277, 7); //k ellip

button(650, 245, 691, 277, 7); //j f ellip

button(608, 279, 647, 310, 7); //c

button(650, 279, 691, 310, 7); //3d

button(608, 312, 647, 340,7); //l

return 'g';

}

}

void returnn()

{

getmouseclick(WM_LBUTTONDOWN, x,y);

if((x>535)&&(y>0)&&(x<700)&&(y<540))

{

open_file();

return;

}

}

Файл «draw.cpp»

#include <graphics.h>

#include <conio.h>

#include <stdio.h>

#include <stdlib.h>

#include <unistd.h>

#include <malloc.h>

#include<math.h>

#include "head.h"

void screen()

{

palette();

setcolor(8);

setlinestyle(0, 0, 5);

setfillstyle(1,10);

bar(0,0, 700, 25); //top panel

setfillstyle(1, 13);

bar(600, 25, 700, 540); // area tools, shapes etc

setfillstyle(1, 10);

bar(600, 25, 700, 50);//file

setlinestyle(0,0, 2);

rectangle(600, 25, 700, 50);

rectangle(600, 25, 700, 510);

rectangle(1, 1, 699, 539);

rectangle(0,509, 699, 539);

rectangle(0,0,700,25);

setbkcolor(13);

setcolor(15);

outtextxy(540, 515, "active collor :");

outtextxy(631, 61, "Tools");

outtextxy(629, 188, "Shapes");

settextstyle(10, 0,1);

setbkcolor(10);

setcolor(13);

outtextxy(632, 30, "File");

setfillstyle(1,15);

bar(604,210,695,346); //for shapes

setcolor(7);

rectangle(604,210,695,346);

readimagefile("exit.bmp", 673, 2, 695, 23);

readimagefile("pencil.bmp", 610, 90, 640, 120); button(604, 83, 647, 127, 15);

readimagefile("fill.bmp", 653, 89,692, 124); button(652, 83, 695, 127, 15);

readimagefile("eraser.bmp", 608, 139, 640, 175); button(604, 134, 647,180, 15);

readimagefile("pipette.bmp", 656, 139, 692, 175); button(652, 134, 695,180, 15);

Источник: https://studfile.net/preview/16570293/