Realization of art clear screen with C language

Source: Internet
Author: User
Tags clear screen

Question: We are in the process of programming, often use to clear screen processing, such as under the DOS under the Cls,turbo C CLRSCR () and so on have clear screen function, but these are the general meaning of the clear screen,

Does not show its clear screen rule. And sometimes in order to achieve the clear screen of the artistic beauty, often on the clear screen has some specific requirements, such as: Opening clear screen, closing the screen; on the clear screen;

The use of C language to develop a number of child functions, used in the program, can not only achieve the purpose of clear screen, there can increase the artistic appearance of the screen.

Child functions and Demo programs:

#include <stdio.h>
#include <dos.h>
#include <conio.h>
void Goto_xy (int x,int y);
void dcls (int x1,int x2,int y1,int y2);
void bcls (int x1,int x2,int y1,int y2);
void kcls (int x1,int x2,int y1,int y2);
void recls (int x1,int x2,int y1,int y2);
void zcls (int x1,int x2,int y1,int y2);
void Puta (void);

/*--------------Demo Program---------------------* *
Main ()
{
Puta ();
Getch ();
Dcls (0,4,0,79);
Getch ();
Puta ();
Getch ();
BCLS (0,25,0,79);
Getch ();
Puta ();
Getch ();
Zcls (0,25,0,79);
Getch ();
}
/*********center Clear Screen (center ***********/)
void zcls (int x1,int x2,int y1,int y2)
{
int x00,y00,x0,y0,i,d;
if ((y2-y1) > (x2-x1)) {
D= (X2-X1)/2;
x0= (X1+X2)/2;
Y0=y1+d;
y00=y2-d;
For (i=0;i< (d+1); i++)
Recls ((x0-i), (X00+i), (Y0-i), (y00+i));
Delay (10);
}
else{
D= (y2-y1)/2;
y0= (Y1+y2)/2;
X0=x1+d;
x00=x2-d;
for (i=0;i<d+1;i++)
Recls (X0-i,x00+i,y0-i,y00+i);
Delay (10);
}
}
/************* Clear Rectangle side (rectangular Benting) ***********************/
void recls (int x1,int x2,int y1,int y2)
{
int i,j;
for (i=y1;i<y2;i++) {
Goto_xy (X1,i);
Putchar (");
Goto_xy (X2,i);
Putchar (");
Delay (10);
}
for (j=x1;j<x2;j++) {
Goto_xy (I,Y1);
Putchar (");
Goto_xy (J,Y2);
Putchar (");
Delay (10);
}
}
/******************open Screen Clear (open screen type) *********************/
void kcls (int x1,int x2,int y1,int y2)
{
int t,s,i,j;
t=s= (Y1+y2)/2;
for (; t<=y2;t++,s--)
for (j=x1;j<x2;j++) {
Goto_xy (j,t);
Putchar (");
Goto_xy (j,s);
Putchar (");
Delay (10);
}
}
/*****************close Screen clear***** Closing Ceremony *******************/
void bcls (int x1,int x2,int y1,int y2)
{
int t,s,j;
T=y1;
S=y2;
For (t=y1;t< (y1+y2)/2;t++,s--)
for (j=x1;j<x2;j++) {
Goto_xy (j,t);
Putchar (");
Goto_xy (j,s);
Putchar (");
Delay (10);
}
}
/******************bottom screen Clear (from down) ********************/
void dcls (int x1,int x2,int y1,int y2)
{
int t,s,j,i;
t=s= (Y1+y2)/2;
for (j=x2;j>x1;j--)
for (i=y1;i<y2;i++) {
Goto_xy (J,i);
Putchar (");
Delay (10);
}
}
/****************** set the cursor child function ******************/
void Goto_xy (int x,int y)
{
Union regs R;
r.h.ah=2;
R.h.dl=y;
R.h.dh=x;
r.h.bh=0;
Int86 (0X10,&AMP;R,&AMP;R);
}
/********************** a series of a letters on the screen to demonstrate the program ******************/
void Puta (void)
{
int i,j;
for (i=0;i<24;i++) {
for (j=0;j<79;j++) {
Goto_xy (I,J);
printf ("a");
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.