program paint; {olh2)C} uses crt,graph,runmouse; {const cursor:array[1..64] of byte = (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);} var x,y,yb :word; LBut,MBut,RBut,wait : boolean; size,color : integer; x_str,y_str,image : string; procedure save_colors(x1, x2, y1, y2: integer; s: string); type arr = array[1 .. maxint div sizeof(word)] of word; var data: ^arr; i, j, k, size: integer; f: file; begin size := (x2 - x1 + 1)*(y2 - y1 + 1)*sizeof(word); getmem(data, size); k := 0; for i := x1 to x2 do for j := y1 to y2 do begin inc(k); data^[k] := getpixel(i, j); end; assign(f, s); rewrite(f, size); blockwrite(f, data^, 1); close(f); freemem(data, size) end; procedure load_colors(x1, x2, y1, y2: integer; s: string); type arr = array[1 .. maxint div sizeof(word)] of word; var data: ^arr; i, j, k, size: integer; f: file; begin size := (x2 - x1 + 1)*(y2 - y1 + 1)*sizeof(word); getmem(data, size); assign(f, s); reset(f, size); blockread(f, data^, 1); close(f); k := 0; for i := x1 to x2 do for j := y1 to y2 do begin inc(k); putpixel(i, j, data^[k]); end; freemem(data, size) end; procedure IGraph; var GD, GM, Error : integer; begin GD := Detect; InitGraph(GD, GM,''); Error := GraphResult; if Error <> grOk then begin writeln('Graphics error:', GraphErrorMsg(Error)); writeln('Press any key...'); readkey; clrscr; halt; end; end; procedure putpoint(x,y,size,color : integer); var i,j,k, center : integer; begin if size > 10 then size := 10; if size < 1 then size := 1; j := 1; for i := 1 to size do begin k := j; j := j + 2; end; size := k; center := size div 2 + 1; for i := 1 to size do for j := 1 to size do if ((i + x - center) > 120) { and ((j + y - center) > 5) and ((i + x - center) < getmaxx-5) and ((i + y - center) < getmaxy-5)} then putpixel(i + x - center, j + y - center, color); end; procedure userscreen; begin y := 25; x := 15; line(120,5,120,getmaxy-5); {line(120,5,getmaxx-5,5); line(getmaxx-5,5,getmaxx-5,getmaxy-5); line(getmaxx-5,getmaxy-5,120,getmaxy-5);} setfillstyle(1,7); bar3d(10,y-15,105,y,4,true);setcolor(0);outtextxy(x,y-10,'Save Image');y := y + 25;setcolor(15); bar3d(10,y-15,105,y,4,true);setcolor(0);outtextxy(x,y-10,'Load Image');y := y + 25;setcolor(15); {bar3d(10,y-15,105,y,4,true);setcolor(0);outtextxy(x,y-10,'Button ');}y := y + 25;setcolor(15); {bar3d(10,y-15,105,y,4,true);setcolor(0);outtextxy(x,y-10,'Button ');}y := y + 25;setcolor(15); bar3d(10,y-15,105,y,4,true);setcolor(0);outtextxy(x,y-10,'Brush Size');y := y + 25;setcolor(15); bar3d(10,y-15,20,y,4,true);setcolor(0);outtextxy(15-3,y-10,'1');setcolor(15); bar3d(25,y-15,35,y,4,true);setcolor(0);outtextxy(30-3,y-10,'2');setcolor(15); bar3d(40,y-15,50,y,4,true);setcolor(0);outtextxy(45-3,y-10,'3');setcolor(15); bar3d(55,y-15,65,y,4,true);setcolor(0);outtextxy(60-3,y-10,'4');setcolor(15); bar3d(70,y-15,80,y,4,true);setcolor(0);outtextxy(75-3,y-10,'5');setcolor(15); bar3d(85,y-15,95,y,4,true);setcolor(0);outtextxy(90-3,y-10,'6');setcolor(15); y := y + 25;setcolor(15); bar3d(10,y-15,105,y,4,true);setcolor(0);outtextxy(x,y-10,'Brush Color');y := y + 25;setcolor(15); setfillstyle(1,0);bar3d(10,y-15,20,y,4,true); setfillstyle(1,1);bar3d(10+20,y-15,20+20,y,4,true); setfillstyle(1,2);bar3d(10+40,y-15,20+40,y,4,true); setfillstyle(1,3);bar3d(10+60,y-15,20+60,y,4,true); y := y + 25;setcolor(15); setfillstyle(1,4);bar3d(10,y-15,20,y,4,true); setfillstyle(1,5);bar3d(10+20,y-15,20+20,y,4,true); setfillstyle(1,6);bar3d(10+40,y-15,20+40,y,4,true); setfillstyle(1,7);bar3d(10+60,y-15,20+60,y,4,true); y := y + 25;setcolor(15); setfillstyle(1,8);bar3d(10,y-15,20,y,4,true); setfillstyle(1,9);bar3d(10+20,y-15,20+20,y,4,true); setfillstyle(1,10);bar3d(10+40,y-15,20+40,y,4,true); setfillstyle(1,11);bar3d(10+60,y-15,20+60,y,4,true); y := y + 25;setcolor(15); setfillstyle(1,12);bar3d(10,y-15,20,y,4,true); setfillstyle(1,13);bar3d(10+20,y-15,20+20,y,4,true); setfillstyle(1,14);bar3d(10+40,y-15,20+40,y,4,true); setfillstyle(1,15);bar3d(10+60,y-15,20+60,y,4,true); setcolor(15); setfillstyle(1,7); bar3d(10,getmaxy-65,105,getmaxy-50,4,true);setcolor(0);outtextxy(25,getmaxy-60,'Clear all');setcolor(15); bar3d(10,getmaxy-40,105,getmaxy-25,4,true);setcolor(0);outtextxy(25,getmaxy-35,'Exit');setcolor(15); end; {----------------------------------------------------------------------} {----------------------------------------------------------------------} {----------------------------------------------------------------------} begin IGraph; resetmouse; {mousegraphcursor(cursor,0,0);} movemousecursor(130,10); showmousecursor; userscreen; size := 1; color := 15; repeat readmousestatus(x,y,LBut,MBut,RBut); if (LBut = true) and (mousein(120+1,5+1,getmaxx-5-1,getmaxy-5-1)) then begin hidemousecursor; putpoint(x,y,size,color); end else begin showmousecursor; if (LBut = true) then begin yb := 185; if mousein(10,yb,20,yb+10) then color := 0; if mousein(10+20,yb,20+20,yb+10) then color := 1; if mousein(10+40,yb,20+40,yb+10) then color := 2; if mousein(10+60,yb,20+60,yb+10) then color := 3; yb := yb + 25; if mousein(10,yb,20,yb+10) then color := 4; if mousein(10+20,yb,20+20,yb+10) then color := 5; if mousein(10+40,yb,20+40,yb+10) then color := 6; if mousein(10+60,yb,20+60,yb+10) then color := 7; yb := yb + 25; if mousein(10,yb,20,yb+10) then color := 8; if mousein(10+20,yb,20+20,yb+10) then color := 9; if mousein(10+40,yb,20+40,yb+10) then color := 10; if mousein(10+60,yb,20+60,yb+10) then color := 11; yb := yb + 25; if mousein(10,yb,20,yb+10) then color := 12; if mousein(10+20,yb,20+20,yb+10) then color := 13; if mousein(10+40,yb,20+40,yb+10) then color := 14; if mousein(10+60,yb,20+60,yb+10) then color := 15; end; if (LBut = true) then begin if (mousein(10,135,20,150)) then size := 1; if (mousein(25,135,35,150)) then size := 2; if (mousein(40,135,50,150)) then size := 3; if (mousein(55,135,65,150)) then size := 4; if (mousein(70,135,80,150)) then size := 5; if (mousein(85,135,95,150)) then size := 6; end; if (LBut = true) and (mousein(10,10,105,25)) then begin setcolor(15); OutTextXY(5,290,'Choose slot to'); OutTextXY(5,300,'save...'); OutTextXY(50,55,'Image 1'); OutTextXY(50,65,'Image 2'); OutTextXY(50,75,'Image 3'); OutTextXY(50,85,'Image 4'); OutTextXY(50,95,'Image 5'); wait := true; repeat readmousestatus(x,y,LBut,MBut,RBut); if (LBut = true) and (mousein(50,55,110,64)) then begin image := 'im1'; wait := false; end; if (LBut = true) and (mousein(50,65,110,74)) then begin image := 'im2'; wait := false; end; if (LBut = true) and (mousein(50,75,110,84)) then begin image := 'im3'; wait := false; end; if (LBut = true) and (mousein(50,85,110,94)) then begin image := 'im4'; wait := false; end; if (LBut = true) and (mousein(50,95,110,104)) then begin image := 'im5'; wait := false; end; until wait = false; hidemousecursor; setcolor(0); OutTextXY(5,290,'Choose slot to'); OutTextXY(5,300,'save...'); OutTextXY(50,55,'Image 1'); OutTextXY(50,65,'Image 2'); OutTextXY(50,75,'Image 3'); OutTextXY(50,85,'Image 4'); OutTextXY(50,95,'Image 5'); setcolor(15); showmousecursor; { save_colors(121,getmaxx,0,getmaxy,image);} outtextxy(160,50, 'FORGET ABOUT IT !!! SAVE FUNCTION ISN''T WORKING NOW! =)'); end; if (LBut = true) and (mousein(10,35,105,50)) then begin hidemousecursor; setcolor(15); OutTextXY(5,290,'Choose slot to'); OutTextXY(5,300,'load...'); OutTextXY(50,55,'Image 1'); OutTextXY(50,65,'Image 2'); OutTextXY(50,75,'Image 3'); OutTextXY(50,85,'Image 4'); OutTextXY(50,95,'Image 5'); showmousecursor; wait := true; repeat readmousestatus(x,y,LBut,MBut,RBut); if (LBut = true) and (mousein(50,55,110,64)) then begin image := 'im1'; wait := false; end; if (LBut = true) and (mousein(50,65,110,74)) then begin image := 'im2'; wait := false; end; if (LBut = true) and (mousein(50,75,110,84)) then begin image := 'im3'; wait := false; end; if (LBut = true) and (mousein(50,85,110,94)) then begin image := 'im4'; wait := false; end; if (LBut = true) and (mousein(50,95,110,104)) then begin image := 'im5'; wait := false; end; until wait = false; hidemousecursor; setcolor(0); OutTextXY(5,290,'Choose slot to'); OutTextXY(5,300,'load...'); OutTextXY(50,55,'Image 1'); OutTextXY(50,65,'Image 2'); OutTextXY(50,75,'Image 3'); OutTextXY(50,85,'Image 4'); OutTextXY(50,95,'Image 5'); setcolor(15); showmousecursor; cleardevice; userscreen; movemousecursor(getmaxx div 2,getmaxy div 2); delay(10000); { load_colors(121,getmaxx,0,getmaxy,image);} outtextxy(160,50, 'FORGET ABOUT IT !!! SAVE FUNCTION ISN''T WORKING NOW! =)'); end; if (LBut = true) and (mousein(10,getmaxy-65,110,getmaxy-50)) then begin cleardevice; userscreen; movemousecursor(110,getmaxy-65); delay(10000); end; if (LBut = true) and (mousein(10,getmaxy-50,110,getmaxy-25)) then begin closegraph; halt; end; { str(x,x_str);str(y,y_str); setcolor(15); outtextxy(5,getmaxy-10,x_str); outtextxy(45,getmaxy-10,y_str); delay(1000); setcolor(0); outtextxy(5,getmaxy-10,x_str); outtextxy(45,getmaxy-10,y_str); setcolor(15); } end; until false; Closegraph; end.