Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Fade text

Posted on 1998-02-07
5
Medium Priority
?
291 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 300 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

886 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