Thread: Colors

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    75

    Colors

    Hi,

    I have the RGB & HSL values of some colors. I want to use to use the RGB or HSL to color the text on my screen.

    And I need to change the background to white.

    Please help me. I am doing this to associate some letters with colors and some other stuff that would be too complicated to explain.

    Thx.


    By the way the code below is the closest I got to what i want but I don;t have all the colors I want.

    Code:
    #define BLACK 0
    #define BLUE 1
    #define GREEN 2
    #define CYAN 3
    #define RED 4
    #define MAGENTA 5
    #define BROWN 6
    #define LIGHTGREY 7
    #define DARKGREY 8
    #define LIGHTBLUE 9
    #define LIGHTGREEN 10
    #define LIGHTCYAN 11
    #define LIGHTRED 12
    #define LIGHTMAGENTA 13
    #define YELLOW 14
    #define WHITE 15
    #define BLINK 128
    
    #include <windows.h>
    #include <iostream>
    using namespace std;
    
    
    int main()
    {
    	
    	srand((unsigned) time(NULL));
    
    	
      cout << "Hello World!" << endl;   
      cout << "Welcome to C++ Programming" << endl; 
      
      
        int k;
      	
      	do{
    	  		  
      	 //SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2); //replace the 0 with a number for the color you want
    	  // 0xFF0000           TextBackground(1)
    	  		 
    	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 3 );		   
    			    
        cin >> k;
        cout <<"\n";
        int n = rand() % 26;
    
    	char c = (char)(n+65);
    	
    	
    		
    	n = rand() % 26;
    	char d = (char)(n+65);
    	cout << c << d << "\n";
    
      }while(k == 0);
    
    
      
      
     return 0;
      }

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    You should use of course
    Code:
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), CYAN)
    nicer than 3, eh?

    Those are probably all the colors you can get, since you only have 8 choices and the ability to intensify them.

    You can use a window application for more colors and features, but that is another story.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 08-01-2010, 02:45 PM
  2. Why I only get 8 colors out of ncurses?
    By Nazgulled in forum C Programming
    Replies: 3
    Last Post: 05-08-2007, 06:06 PM
  3. Relation between material colors and light colors.
    By indigo0086 in forum Game Programming
    Replies: 3
    Last Post: 04-18-2007, 03:20 PM
  4. colors in forefox and colors in IE
    By MisterSako in forum Tech Board
    Replies: 3
    Last Post: 05-15-2006, 01:59 PM
  5. Text Colors
    By GaPe in forum C Programming
    Replies: 1
    Last Post: 07-11-2002, 06:57 AM