|
more than 450 programs for free
|
![]() English |
![]() Slovensky |
![]() Èesky |
![]() ©ari¹sky |
Category: Programs in C, C++![]() Program: Fapa.c, Help.c, Help.h, Mys.c, Mys.h File exe: Fapa.exe need: Egavga.bgi, Help.txt, Litt.chr, Trip.chr The program presents the ways of mixing the colors. It's base on the following methods
Models used: RGB - red, green, blue CMY - cyan, magenta, yellow HSV - Hue saturation value HLS - Hue lightness value Views: 1438x
// FAPA.C Copyright (c) TrSek alias Zdeno Sekerak // Program ktory nazorne ukazuje sposob miesania farieb na zaklade // tychto metod: RGB, CMY, HSV alebo HLS. // Vsetko je nazorne popasane a je mozne online menit hodnoty. // // Datum:14.12.1994 http://www.trsek.com #include <string.h> #include <graphics.h> #include <dos.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> #include <alloc.h> #include <math.h> #include <time.h> #include "help.h" #include "mys.h" char *tex[]={"ESC-Exit","F1-Help","","F3-RGB","F4-CMY","F5-HSV", "F6-HLS","F7-GRAY","F8-Old","F9-FAPA"}; char *col[][3]={{"BLUE","GREEN","RED"},{"YELLOW","MAGENTA","CYAN"},{"HUGE","SATURATION","VOLUME"}, {"HUGE","SYTOST","LIGHT"},{"GRAY","",""},{"","",""}, {"OLD","OLD","OLD"}}; void GetPath(char* cesta,char* args); char* JoinPath(char* cesta,char* subor); void uvod( int ); void fapa( void ); void butfree( int, int, int, int, int, int); void butput ( int, int, int, int, int, int); void button ( int, int ); void movbut ( int, int ); void uvod_kre( int , int); void prac_obr( void ); int vykonat(char *); void init_pot( void ); void oz_col ( void ); void get_rgb ( float * , int ); void put_rgb ( float * , int ); void prev_to_rgb ( void ); void prev_from_rgb ( void ); int help ( void ); void press ( void ); void change( int ); void duha ( void ); int minmax( int , int , int , int ); void zhasni( void ); int strana( int , int , char * , FILE * ); unsigned far *butmap; float butony[4],oldbut[4]; int inbut,akcol,typpa,old_akcol,po; int gmaxx,gmaxy; char cesta[128]; void main(int argv, char* args[]) { int i,y; int ch; int but,xm,ym; int pomer,pomy; float oldc[256][3]; unsigned size; int drv = DETECT, mode = 0 ; char kam[128]; // zisti cestu spustania GetPath(cesta, args[0]); detectgraph( &drv, &mode ); initgraph( &drv, &mode, JoinPath(cesta, "egavga.bgi")); setbkcolor(BLUE); cleardevice(); gmaxx=getmaxx();gmaxy=getmaxy(); size=imagesize(gmaxx-89,137,gmaxx-80,151); butmap=(unsigned int far*) _graphgetmem(size); if (butmap==NULL) inbut=0; else inbut=1; uvod_kre(1,0); for (i=0;i<=getmaxcolor();i++) get_rgb(oldc[i],i); oldc[0][1]=0;oldc[0][2]=0;oldc[0][3]=0; ch=0;randomize(); do { for (i=0;i<=getmaxcolor();i++) { if ((i!=RED) && (i!=YELLOW) && (i!=BLUE)) { butony[1]=random(gmaxy-206); butony[2]=random(gmaxy-206); butony[3]=random(gmaxy-206); put_rgb(butony,i); } } //sound(random(1000)); delay(100);nosound(); if (kbhit()) ch=getch(); } while (ch!=13); zhasni(); prac_obr(); butony[1]=1;butony[2]=1;butony[3]=1; oldbut[1]=1;oldbut[2]=1;oldbut[3]=1; getimage(gmaxx-89,137,gmaxx-80,151,butmap); typpa=3;akcol=0;old_akcol=0; button(typpa,1); init_mys(); po=0; for (i=0;i<=getmaxcolor();i++) { butony[1]=oldc[i][1];butony[2]=oldc[i][2];butony[3]=oldc[i][3]; put_rgb(butony,i); } oz_col(); do { zobmys(1); getmys( &but, &xm, &ym ); if (but==2) { ch=27;button(0,1); } if (but==1) { zobmys(0); if ((ym<=40) && (ym>=15)) { if ((xm>=20) && (xm<=70)) { button(0,1);ch=27; } if ((xm>=81) && (xm<=131)) { button(1,1);help();button(1,0);} if ((xm>=203) && (xm<=253)) { button(typpa,0);change(0);button(3,1);} if ((xm>=264) && (xm<=304)) { button(typpa,0);change(1);button(4,1);} if ((xm>=325) && (xm<=365)) { button(typpa,0);change(2);button(5,1);} if ((xm>=386) && (xm<=426)) { button(typpa,0);change(3);button(6,1);} if ((xm>=447) && (xm<=487)) { if (vykonat("Prekonvertovaœ na çed£ çk lu.")) { button(typpa,0);button(7,1); for (i=0;i<=getmaxcolor();i++) {akcol=i;oz_col(); butony[1]=i*((gmaxy-206)/getmaxcolor()); butony[2]=butony[1];butony[3]=butony[1]; butony[1]=butony[2]; oldbut[3]=butony[2];oldbut[2]=butony[2]; oldbut[1]=butony[2]; movbut(1,0);} akcol=0;duha();oz_col();change(4);button(7,1);}} if ((xm>=508) && (xm<=548)) { if (vykonat("Vr tiœ p“vodn‚ farby.")) { button(typpa,0);button(8,1);change(6); for (i=0;i<=getmaxcolor();i++) { butony[1]=oldc[i][1];butony[2]=oldc[i][2];butony[3]=oldc[i][3]; oldbut[1]=oldc[i][1];oldbut[2]=oldc[i][2];oldbut[3]=oldc[i][3]; akcol=i; movbut(1,0); } duha();typpa=3;akcol=0;oz_col();change(0); button(8,0); button(3,1);}} if ((xm>=569) && (xm<=609)) {button(9,1);fapa();button(9,0);} } if ((ym<=gmaxy-50) && (ym>=135)) { xm=gmaxx-xm; if ((xm<=93) && (xm>=77)) { do { set_mys(gmaxx-20,gmaxy/2); getmys( &but, &xm, &ym); if (ym<gmaxy/2) for (i=ym;i<=gmaxy/2;i=i+2) movbut(3,-2); if (ym>gmaxy/2) for (i=gmaxy/2;i<=ym;i=i+2) movbut(3, 2); } while (but==1); set_mys(gmaxx-80,140); ym=0;xm=0; } if ((xm<=64) && (xm>=48)) { do { set_mys(gmaxx-50,gmaxy/2); getmys( &but, &xm, &ym); if (ym<gmaxy/2) for (i=ym;i<=gmaxy/2;i=i+2) movbut(2,-2); if (ym>gmaxy/2) for (i=gmaxy/2;i<=ym;i=i+2) movbut(2, 2); } while (but==1); set_mys(gmaxx-50,140); ym=0;xm=0; } if ((xm<=35) && (xm>=20)) { do { set_mys(gmaxx-25,gmaxy/2); getmys( &but, &xm, &ym); if (ym<gmaxy/2) for (i=ym;i<=gmaxy/2;i=i+2) movbut(1,-2); if (ym>gmaxy/2) for (i=gmaxy/2;i<=ym;i=i+2) movbut(1, 2); } while (but==1); set_mys(gmaxx-25,140); ym=0;xm=0; } xm=gmaxx-xm; } if ((ym>=55) && (ym<=gmaxy-50)) if ((xm>=20) && (xm<=gmaxx-107)) { pomer=((gmaxx-127)/16); pomy=getmaxcolor()/16+1; ym=ym/((gmaxy-127)/pomy); xm=(xm-20)/pomer+ym*16; if ((xm>=0) && (xm<=15)) {akcol=ym*16+xm;oz_col();} } zobmys(1); } if (kbhit()) ch=getch(); else if (ch!=27) ch=1; if (ch==27) button(0,1); if ((ch==113) || (ch==81)) movbut(3,-2); /*pre Q*/ if ((ch==119) || (ch==86)) movbut(2,-2); /*pre W*/ if ((ch==101) || (ch==69)) movbut(1,-2); /*pre E*/ if ((ch==97 ) || (ch==65)) movbut(3, 2); /*pre A*/ if ((ch==115) || (ch==83)) movbut(2, 2); /*pre S*/ if ((ch==100) || (ch==68)) movbut(1, 2); /*pre D*/ if (ch==0) { if (kbhit) { zobmys(0); ch=getch(); switch (ch) { case 59: button(1,1);help();button(1,0);break; case 61: button(typpa,0);change(0);button(3,1);break; case 62: button(typpa,0);change(1);button(4,1);break; case 63: button(typpa,0);change(2);button(5,1);break; case 64: button(typpa,0);change(3);button(6,1);break; case 65: if (vykonat("Prekonvertovaœ na çed£ çk lu.")) { button(typpa,0);button(7,1); for (i=0;i<=getmaxcolor();i++) { butony[1]=i*((gmaxy-206)/getmaxcolor()); butony[2]=butony[1];butony[3]=butony[1]; butony[1]=butony[2]; oldbut[3]=butony[2];oldbut[2]=butony[2]; oldbut[1]=butony[2]; movbut(1,0);akcol=i;oz_col();} duha();akcol=0;oz_col();change(4);button(7,1); } break; case 66: if (vykonat("Vr tiœ p“vodn‚ farby.")) { button(typpa,0);button(8,1);change(6); for (i=0;i<=getmaxcolor();i++) { butony[1]=oldc[i][1];butony[2]=oldc[i][2];butony[3]=oldc[i][3]; oldbut[1]=oldc[i][1];oldbut[2]=oldc[i][2];oldbut[3]=oldc[i][3]; akcol=i; movbut(1,0); } duha();typpa=3;akcol=0;oz_col();change(0); button(8,0); button(3,1);}break; case 67: button(9,1);fapa();button(9,0);break; case 75: if (akcol>0) akcol=akcol-1;oz_col();break; case 77: if (akcol<getmaxcolor()) akcol=akcol+1;oz_col();break; } zobmys(1); } } if (ch==27) if (vykonat("Chceç ukonŸiœ program FAPA.")==0) ch=0; } while (ch!=27); closegraph(); } // prepocet na suradnice podla x,y-rozlisenia monitora int rcmx(int x) { return x*640.0/gmaxx; } int rcmy(int y) { return y*480.0/gmaxy; } void uvod_kre(int vse, int pos ) { int i; if (vse==1) for (i=1;i<=gmaxx/2;i++) uvod(i); setfillstyle(1,BLUE);i=(1.0*gmaxx)/4.7; butfree(i,i+pos,gmaxx-i,gmaxy-i+pos,10,RED); setcolor(YELLOW); settextstyle(1,0,9); outtextxy(i+20,i-10+pos," FAPA"); settextstyle(2,0,9); outtextxy(i+65,i+80+pos,"Farebn paleta"); settextstyle(2,0,6); outtextxy(i+50,i+113+pos,"PoŸ¡taŸov grafika 14.12.1994"); outtextxy(i+70,i+130+pos,"predn çaj£ci:doc.æujanskì"); outtextxy(i+100,i+147+pos,"cviŸiaci:ing.Sobota"); butfree(i+100,i+177+pos,gmaxx-i-100,gmaxy-i-8+pos,5,BLUE); outtextxy(i+135,i+177+pos,"StlaŸ ENTER"); setfillstyle(1,RED);i=gmaxx/4; butfree(i,i+200+pos,gmaxx-i,gmaxy-i+135+pos,10,BLUE); setcolor(YELLOW); settextstyle(2,0,6); outtextxy(i+130,i+210+pos,"Autori:"); outtextxy(i+40,i+228+pos,"Zdeno Seker k alias TRSEK"); outtextxy(i+110,i+246+pos,"Gabriel Sille"); outtextxy(i+25,i+264+pos,"FEI TU Koçice - III.A/5 ç.sk."); } void uvod(int od) { setcolor(od); line(od,od,gmaxx-od,od); line(gmaxx-od,od,gmaxx-od,gmaxy-od); line(gmaxx-od,gmaxy-od,od,gmaxy-od); line(od,gmaxy-od,od,od); } // zobrazenie buttonu void butfree(int x1, int y1, int x2, int y2, int but, int col) { int i; setfillstyle(1,col); bar(rcmx(x1),rcmy(y1),rcmx(x2),rcmy(y2)); setcolor(WHITE); for (i=1;i<=but;i++) { line(rcmx(x2+i),rcmy(y1-i),rcmx(x1-i),rcmy(y1-i)); line(rcmx(x1-i),rcmy(y1-i),rcmx(x1-i),rcmy(y2+i)); } setcolor(DARKGRAY); for (i=1;i<=but;i++) { line(rcmx(x2+i),rcmy(y1-i),rcmx(x2+i),rcmy(y2+i)); line(rcmx(x2+i),rcmy(y2+i),rcmx(x1-i),rcmy(y2+i)); } } // uvodna obrazovka programu void fapa( void ) { uvod_kre(0,-40); settextstyle(2,1,4); press(); duha(); oz_col(); } int vykonat(char sprava[]) { int x,y,but,konc; char ch; int font; font=installuserfont("litt"); settextstyle(font,0,6); butfree(80,150,gmaxx-150,gmaxy-250,6,LIGHTGRAY); setcolor(DARKGRAY); outtextxy(80+(360.0-8*strlen(sprava))/2,160,sprava); butfree(170,200,220,220,3,LIGHTGRAY); outtextxy(183,200,"Ano"); butfree(350,200,400,220,3,LIGHTGRAY); outtextxy(363,200,"Nie"); konc=-1; do { getmys(&x,&y,&but); if (but==1) { if ((x>170) && (x<220) && (y>200) && (y<220)) { konc=1; butput(170,200,220,220,3,LIGHTGRAY); outtextxy(183,200,"Ano"); } if ((x>350) && (x<400) && (y>200) && (y<220)) { konc=0; butput(350,200,400,220,3,LIGHTGRAY); outtextxy(363,200,"Nie"); } } if (kbhit()) { ch=getch(); if ((ch==65) || (ch== 97)) { konc=1; butput(170,200,220,220,3,LIGHTGRAY); outtextxy(183,200,"Ano"); } if ((ch==78) || (ch==110)) { konc=0; butput(350,200,400,220,3,LIGHTGRAY); outtextxy(363,200,"Nie"); } } } while ((konc!=0) && (konc!=1)); settextstyle(2,0,5); duha(); oz_col(); return(konc); } void butput (int x1, int y1, int x2, int y2, int but, int col) { int i; setfillstyle(1,col); bar(rcmx(x1),rcmy(y1),rcmx(x2),rcmy(y2)); setcolor(DARKGRAY); for (i=1;i<=but;i++) { line(rcmx(x2+i),rcmy(y1-i),rcmx(x1-i),rcmy(y1-i)); line(rcmx(x1-i),rcmy(y1-i),rcmx(x1-i),rcmy(y2+i)); } setcolor(WHITE); for (i=1;i<=but;i++) { line(rcmx(x2+i),rcmy(y1-i),rcmx(x2+i),rcmy(y2+i)); line(rcmx(x2+i),rcmy(y2+i),rcmx(x1-i),rcmy(y2+i)); } } void button(int porad, int ako ) { settextstyle(2,0,4); if (ako) { butput(20+porad*61, 15, 70+porad*61, 40, 3,LIGHTGRAY); setcolor(DARKGRAY); outtextxy(25+porad*61, 20, tex[porad]); if (porad>2) { oz_col(); init_pot(); } } else { butfree(20+porad*61,15,70+porad*61,40,3,LIGHTGRAY); outtextxy(25+porad*61,20,tex[porad]); } } void init_pot( void ) { int y,i; float krok; butfree(gmaxx-93,135,gmaxx-77,gmaxy-50,3,LIGHTGRAY); butfree(gmaxx-64,135,gmaxx-48,gmaxy-50,3,LIGHTGRAY); butfree(gmaxx-35,135,gmaxx-20,gmaxy-50,3,LIGHTGRAY); butfree(gmaxx-87,137,gmaxx-82,138+butony[3],2,LIGHTGRAY); butfree(gmaxx-58,137,gmaxx-53,138+butony[2],2,LIGHTGRAY); butfree(gmaxx-29,137,gmaxx-24,138+butony[1],2,LIGHTGRAY); butfree(gmaxx-93,gmaxy-35,gmaxx-77,gmaxy-15,3,LIGHTGRAY); butfree(gmaxx-64,gmaxy-35,gmaxx-48,gmaxy-15,3,LIGHTGRAY); butfree(gmaxx-35,gmaxy-35,gmaxx-20,gmaxy-15,3,LIGHTGRAY); krok=0;setcolor(DARKGRAY);y=i=0;y=y+1; if ((141<=gmaxy-56) && (((gmaxy-197)/50)>0)) for (i=141;i<=gmaxy-56;i=i+(gmaxy-197)/50,krok=krok+0.25) { line(gmaxx-93,i,gmaxx-92,i); line(gmaxx-64,i,gmaxx-63,i); line(gmaxx-35,i,gmaxx-34,i); if (krok==(y=krok)) { line(gmaxx-93,i,gmaxx-90,i); line(gmaxx-64,i,gmaxx-61,i); line(gmaxx-35,i,gmaxx-32,i); } } for (i=1;i<=3;i++) movbut(i,0); } void prac_obr( void ) { int i; setbkcolor(LIGHTGRAY); cleardevice(); setfillstyle(1,LIGHTGRAY); butfree(5,5,gmaxx-5,gmaxy-5,5,LIGHTGRAY); setfillstyle(1,BLUE); settextstyle(2,0,4); for (i=0;i<=9;i++) { if (i!=2) { butfree(20+i*61,15,70+i*61,40,3,LIGHTGRAY); outtextxy(25+i*61,20,tex[i]); } } setbkcolor(BLACK); butfree(20,55,gmaxx-107,gmaxy-50,3,BLACK); butfree(20,gmaxy-35,gmaxx-200,gmaxy-15,3,LIGHTGRAY); outtextxy(25,gmaxy-33,"FAREBNA PALETA (c) 1994, Software by TRSEK & Sille. PoŸ¡taŸov grafika"); butfree(gmaxx-183,gmaxy-35,gmaxx-107,gmaxy-15,3,LIGHTGRAY); outtextxy(gmaxx-178,gmaxy-33,"Percent ->"); butfree(gmaxx-93,55,gmaxx-77,125,3,LIGHTGRAY); butfree(gmaxx-64,55,gmaxx-48,125,3,LIGHTGRAY); butfree(gmaxx-35,55,gmaxx-20,125,3,LIGHTGRAY); init_pot(); settextstyle(2,1,4); for (i=1;i<=3;i++) outtextxy(gmaxx-7-i*28,57,col[0][i-1]); duha(); } // robi efekt prelinania sa farieb void duha( void ) { int x,y,pomer,pomy; pomer=(gmaxx-127)/16; pomy=getmaxcolor()/16; if (pomy==0) pomy=1; for (y=0;y<=pomy-1;y++) for (x=20;x<=gmaxx-107;x++) { setcolor(((y*(gmaxx-127)+x-20)/pomer)); line(x,y*((gmaxy-105)/pomy)+55,x,55+(y+1)*((gmaxy-105)/pomy)); } } // zobrazi help subor int help( void ) { int font,s,y,x,but,good; char ch,re[80],re2[2]; FILE *fopen(),*f; char kam[128]; butfree(20,55,gmaxx-57,gmaxy-50,3,LIGHTGRAY); settextstyle(2,0,5); butfree(40,gmaxy-80,140,gmaxy-60,2,LIGHTGRAY); butfree(180,gmaxy-80,280,gmaxy-60,2,LIGHTGRAY); butfree(320,gmaxy-80,430,gmaxy-60,2,LIGHTGRAY); butfree(470,gmaxy-80,570,gmaxy-60,2,LIGHTGRAY); setcolor(DARKGRAY); outtextxy(50,gmaxy-81,"PgUp-Hore"); outtextxy(190,gmaxy-81,"PgDn-Dole"); outtextxy(330,gmaxy-81,"Enter-Koniec"); outtextxy(480,gmaxy-81,"Strana:"); font=installuserfont("litt"); settextstyle(font,0,6); f=fopen(JoinPath(cesta,"help.txt","r"); if (f==NULL) return(0); s=-1;re2[1]='\0'; sprintf(re,"%3d",s+1); outtextxy(536,gmaxy-81,re); do { bar(20,55,gmaxx-57,gmaxy-83); if (s==-1) { settextstyle(font,0,4); obrazky(); good=0; settextstyle(font,0,6); } else { if ((good=strana(1,s,re,f))==0) { for (y=1;y<=20;y++) { setcolor(DARKGRAY); for (x=0;x<=strlen(re);x++) { re2[0]=re[x]; if (re[x]=='@') setcolor(YELLOW); else outtextxy(40+x*8,45+y*16,re2); } if ((good=strana(0,s,re,f))!=0) y=21; } } } ch=0;zobmys(1); do { getmys(&but,&x,&y); if (but==1) { y=gmaxy-y; if ((y<80 |