DESSINER DES CADRES EN COULEURS AVEC DIFFERENTS EFFETS
Source / Exemple :
// PROGRAMME EN C SOUS DOS TURBO C++ BORLAND
// ecrit le 15-04-2002 par cmarsc
// DESSINER DES CADRES EN COULEURS
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <stdlib.h>
// remplace delay si non disponible dans votre bibliotheque
void ralentir(void);
void box_haut_bas( int col, int ligne_depart, int ligne_fin);
void box_bas_haut( int col, int ligne_depart, int ligne_fin);
void box_droite_gauche(int col_dep,int col_fin,int ligne_dep,int ligne_fin);
void box_gauche_droite(int col_dep,int col_fin,int ligne_dep,int ligne_fin);
void box_50_50(int col, int ligne_depart, int ligne_fin);
int main(void) {
char votre_choix;
_setcursortype(_NOCURSOR); // supprimer le curseur clignotant
textcolor(15);
while(1) { // TAPER ESC POUR SORTIR
sleep(1);
// ecran de depart
textbackground(CYAN); // fond vert
clrscr(); // effacer ecran
textcolor(YELLOW); // texte jaune
gotoxy(15,12);
cprintf("TAPER UN CHIFFRE ENTRE 1 et 5 ESC pour sortir ");
votre_choix = getch();
switch (votre_choix) {
case '1' :
// col = 10 ligne depart = 3 ligne fin = 23
box_haut_bas(10,3,23);
break;
case '2':
// col = 10 ligne depart = 24 ligne fin = 1
box_bas_haut(10,24,1);
break;
case '3':
// col dep = 75 col fin = 20 ligne depart = 5 ligne fin = 20
box_droite_gauche(75,20, 5,20);
break;
case '4':
// col dep = 75 col fin = 20 ligne depart = 5 ligne fin = 20
box_gauche_droite(10,50,5,15);
break;
case '5':
// col = 5 ligne_depart = 13 ligne_fin = 1
box_50_50(3,13,1);
break;
case 27: exit(0); // sortir du programme
break;
default:
break;
}
} // fin de while(1)
// return 0;
} // fin de main
void ralentir(void) {
int i0;
for (i0 = 0; i0 < 1500; i0++){
gotoxy(1,1);
cputs("");
}
return;
}
void box_haut_bas(int col, int ligne_depart, int ligne_fin) {
int i1;
textbackground(BLUE);
for (i1 = 0;ligne_depart+i1 < ligne_fin; i1++){
gotoxy(col,ligne_depart+i1);
// 60 = largeur du cadre
cprintf("%60c",'\0');
ralentir();
}
return;
}
void box_bas_haut(int col, int ligne_depart, int ligne_fin) {
int i1;
textbackground(RED);
for (i1 = 0;ligne_depart-i1 > ligne_fin; i1++){
gotoxy(col,ligne_depart-i1);
// 40 = largeur du cadre
cprintf("%40c",'\0');
ralentir();
}
return;
}
void box_droite_gauche(int col_dep,int col_fin,int ligne_dep,int ligne_fin) {
int i1, i2;
textbackground(BLACK);
for (i1 = col_dep; i1 > col_fin; i1--) {
for (i2 = 0; ligne_dep + i2 < ligne_fin; i2++) {
gotoxy(i1,ligne_dep + i2);
cprintf("%1c",'\0');
}
ralentir();
}
return;
}
void box_gauche_droite(int col_dep,int col_fin,int ligne_dep,int ligne_fin) {
int i1, i2;
textbackground(YELLOW);
for (i1 = 0; i1 < col_fin; ++i1) {
for (i2 = 0; i2 < ligne_fin; i2++) {
gotoxy(col_dep + i1, ligne_dep + i2);
cprintf("%1c",'\0');
}
ralentir();
}
return ;
}
void box_50_50(int col, int ligne_depart, int ligne_fin) {
int i1;
textbackground(BLUE);
for (i1 = 0; ligne_depart - i1 > ligne_fin ; ++i1) {
// monter
gotoxy(col,ligne_depart - i1);
// largeur = 75
cprintf("%75c",'\0');
// descendre
gotoxy(col,ligne_depart + i1);
cprintf("%75c",'\0');
ralentir();
}
return ;
}
Conclusion :
// PROGRAMME EN C SOUS DOS TURBO C++ BORLAND
// ecrit le 15-04-2002 par cmarsc
// DESSINER DES CADRES EN COULEURS
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.