Solved

Fade text

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
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 writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

760 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

18 Experts available now in Live!

Get 1:1 Help Now