Solved

Fade text

Posted on 1998-02-07
5
283 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
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.

813 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now