Solved

Fade text

Posted on 1998-02-07
5
284 Views
Last Modified: 2010-04-02
How do you fade a text string in c.
I use Turbo c for dos.
I need source
0
Comment
Question by:hh
  • 3
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
Ready4Dis earned 100 total points
ID: 1257186
This is only for fading the color white out. If you need more, tell me, and I will do it.
Ok... here is the source:

#include <conio.h>
#include <stdio.h>
#include <dos.h>

main ()
{
      int i;
      clrscr();
      printf("Hello");  //here is the text.
      for (i=45;i>0;i--)
      {
            outportb(0x3c8,7);
            outportb(0x3c9,i);
            outportb(0x3c9,i);
            outportb(0x3c9,i);
            delay(100);  //Change for faster/slower fade
      }
            //Resets port...
            outportb(0x3c8,7);
            outportb(0x3c9,45);
            outportb(0x3c9,45);
            outportb(0x3c9,45);
return 0;
}
0
 

Author Comment

by:hh
ID: 1257187
Here is the source to fade out of white, into red, then out of red, and back to white.  Look for comments to changge colors.

#include <conio.h>
#include <stdio.h>
#include <dos.h>

main ()
{
      int i;
      clrscr();
      printf("Hello");  //here is the text.
      for (i=45;i>0;i--)
      {
            outportb(0x3c8,7);
            outportb(0x3c9,i);  //Red
            outportb(0x3c9,i);  //Green
            outportb(0x3c9,i);  //Blue
            delay(100);  //Change for faster/slower fade
      }
      for (i=0;i<45;i++)
      {
            outportb(0x3c8,7);
            outportb(0x3c9,i);  //Fade into Red.
            outportb(0x3c9,0);
            outportb(0x3c9,0);
            delay(100);  //Change for faster/slower fade
      }
      for (i=45;i>0;i--)
      {
            outportb(0x3c8,7);
            outportb(0x3c9,i);  //Fade out of Red.
            outportb(0x3c9,0);
            outportb(0x3c9,0);
            delay(100);  //Change for faster/slower fade
      }
            //Resets port...
            outportb(0x3c8,7);
            outportb(0x3c9,45);
            outportb(0x3c9,45);
            outportb(0x3c9,45);
return 0;
}
0
 
LVL 2

Expert Comment

by:Ready4Dis
ID: 1257188
How do you flash the whole screen
0
 

Author Comment

by:hh
ID: 1257189
#include <conio.h>
#include <stdio.h>
#include <dos.h>
main ()
{
int i;
clrscr();
for (i=0;i<45;i++)
{
outportb(0x3c8,0);
outportb(0x3c9,i); //Red
outportb(0x3c9,i); //Green
outportb(0x3c9,i); //Blue
delay(100); //Change for faster/slower fade
}
for (i=45;i>0;i--)
{
outportb(0x3c8,0);
outportb(0x3c9,i);
outportb(0x3c9,i);
outportb(0x3c9,i);
delay(100); //Change for faster/slower fade
}
return 0;
}
0
 
LVL 2

Expert Comment

by:Ready4Dis
ID: 1257190
//Flash whole screen
#include <conio.h>
#include <stdio.h>

main ()
{
  outportb(0x3c8,0);
  outportb(0x3c9,63); //Red
  outportb(0x3c9,0); //Green
  outportb(0x3c9,0); //Blue
  getch();  //Wait for keypress
  outportb(0x3c8,0);
  outportb(0x3c9,0); //Red
  outportb(0x3c9,0); //Green
  outportb(0x3c9,0); //Blue
  return 0;
}
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
cURL: stopping a http transaction before it's finished 3 126
C language IDE – Compilers installation 14 74
Unable to start eclipse ? 17 153
Super Scope, DHCP 5 91
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question