C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28695
Number of posts: 94715

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
how to make your own color in c++? Posted by deostroll on 17 Jan 2006 at 3:04 AM
I would appreciate anyone who is well versed with turbo c++ v 3.0 to reply to this post. If you believe you can answer this post otherwise then you are most welcome...!

I would like a c or c++ program in which i can make my own colour (in the graphics mode)? And I don't have that much of knowledge of assembly either. So i guess this will be difficult. But do try giving me the required logic/theory behind constructing this program. I guess it would be of great help!!!
Report
Re: how to make your own color in c++? Posted by John Erick on 17 Jan 2006 at 5:43 AM
: I would appreciate anyone who is well versed with turbo c++ v 3.0 to reply to this post. If you believe you can answer this post otherwise then you are most welcome...!
:
: I would like a c or c++ program in which i can make my own colour (in the graphics mode)? And I don't have that much of knowledge of assembly either. So i guess this will be difficult. But do try giving me the required logic/theory behind constructing this program. I guess it would be of great help!!!
:
Good Day!!Iam john erick of the philippines and I can help you on your problem. But first, I want you to answer my question to you.

which directive are you using the "#include<stdio.h>" with the " #include<graphics.h>" or "#include<iostream.h>"?

If you are using the "#include<stdio.h>", I can help you. And to contact me, please send me an Email through <jirai_ekibyo_drakmord@yahoo.com> But if dont, sorry to tell you that I am not very aware of that directive.
Report
Re: how to make your own color in c++? Posted by John Erick on 17 Jan 2006 at 5:59 AM
: I would appreciate anyone who is well versed with turbo c++ v 3.0 to reply to this post. If you believe you can answer this post otherwise then you are most welcome...!
:
: I would like a c or c++ program in which i can make my own colour (in the graphics mode)? And I don't have that much of knowledge of assembly either. So i guess this will be difficult. But do try giving me the required logic/theory behind constructing this program. I guess it would be of great help!!!
:

hELLO!! Again, I'm john. I want to answer your question regarding on graphics in C.

To make your text color, read this pls.:

sample program:
------------------------
#include<stdio.h> |
#include<conio.h> |
#include<graphics.h> |
main() |
{ |
clrscr(); |
printf("\033[2J"); |
printf("\nHello!!"); |
getch(); |
} |
------------------------
/*The example above uses 3 escape characters. The first 0 sets the text mode to 40 colomns and 25 rows . The second 33 sets the foreground text color to yellow. The last [2J clears the screen.*/

The list below shows the escape characters that are supported:


/* escape characters used for changig color */

foreground color attributes

30 black
31 red
32 green
33 yellow
34 blue
35 magenta
36 cyan
37 white


background color attributes


40 black
41 red
42 green
43 yellow
44 blue
45 magenta
46 cyan
47 white


/* escape characters used to change text attributes */

0 switches off all other attributes
1 bold text
4 underlined text
5 blinking text
7 invers display
8 characters not visible on screen

/* escape characters used to change video mode */
video mode settings

0 40 cols, 25 rows, monochrom text
1 40 cols, 25 rows, color text
2 80 cols, 25 rows, monochrom text
3 80 cols, 25 rows, color text


4 320*200 pxl, screen resolution, multi-color
5 320*200 pxl, monochrom graphics
6 640*200 pxl, monchrom graphics
7 characters at the end of a line will be taken to next line


13 320*200 pxl screen resolution, color graphics
14 640*200 pxl 16 color graphics
15 640*350 pxl monochrom graphics (2 color)
16 640*350 pxl 16 color graphics
17 640*480 pxl monochrom graphics (2 color)
18 640*480 pxl 16 bit color
19 320*200 pxl 256 color graphics

Did you get it? If not, pleasepost your questions again in the message board. Thanks. &#9786; &#9786; &#9786;

Report
Re: how to make your own color in c++? Posted by MT2002 on 17 Jan 2006 at 7:17 PM
: : I would appreciate anyone who is well versed with turbo c++ v 3.0 to reply to this post. If you believe you can answer this post otherwise then you are most welcome...!
: :
: : I would like a c or c++ program in which i can make my own colour (in the graphics mode)? And I don't have that much of knowledge of assembly either. So i guess this will be difficult. But do try giving me the required logic/theory behind constructing this program. I guess it would be of great help!!!
: :
:
: hELLO!! Again, I'm john. I want to answer your question regarding on graphics in C.
:
: To make your text color, read this pls.:
:
: sample program:
: ------------------------
: #include<stdio.h> |
: #include<conio.h> |
: #include<graphics.h> |
: main() |
: { |
: clrscr(); |
: printf("\033[2J"); |
: printf("\nHello!!"); |
: getch(); |
: } |
: ------------------------
: /*The example above uses 3 escape characters. The first 0 sets the text mode to 40 colomns and 25 rows . The second 33 sets the foreground text color to yellow. The last [2J clears the screen.*/
:
: The list below shows the escape characters that are supported:
:
:
: /* escape characters used for changig color */
:
: foreground color attributes
:
: 30 black
: 31 red
: 32 green
: 33 yellow
: 34 blue
: 35 magenta
: 36 cyan
: 37 white
:
:
: background color attributes
:
:
: 40 black
: 41 red
: 42 green
: 43 yellow
: 44 blue
: 45 magenta
: 46 cyan
: 47 white
:
:
: /* escape characters used to change text attributes */
:
: 0 switches off all other attributes
: 1 bold text
: 4 underlined text
: 5 blinking text
: 7 invers display
: 8 characters not visible on screen
:
: /* escape characters used to change video mode */
: video mode settings
:
: 0 40 cols, 25 rows, monochrom text
: 1 40 cols, 25 rows, color text
: 2 80 cols, 25 rows, monochrom text
: 3 80 cols, 25 rows, color text
:
:
: 4 320*200 pxl, screen resolution, multi-color
: 5 320*200 pxl, monochrom graphics
: 6 640*200 pxl, monchrom graphics
: 7 characters at the end of a line will be taken to next line
:
:
: 13 320*200 pxl screen resolution, color graphics
: 14 640*200 pxl 16 color graphics
: 15 640*350 pxl monochrom graphics (2 color)
: 16 640*350 pxl 16 color graphics
: 17 640*480 pxl monochrom graphics (2 color)
: 18 640*480 pxl 16 bit color
: 19 320*200 pxl 256 color graphics
:
: Did you get it? If not, pleasepost your questions again in the message board. Thanks. &#9786; &#9786; &#9786;
:
:

<graphics.h> is an old borland header, and is borland
specific--ie; nonstandard.

Are you using DOS? If so, you can either use <dos.h>
or inline asm. <dos.h> is more standard then <graphics.h>
(Although I believe it is depreciated.)

Of course, if this isnt an issue, <graphics.h> might be
a better option.

(Why did they use escape chars to set video modes??)
That just doesnt make sense, imo.

~mt2002

Report
Re: how to make your own color in c++? Posted by stober on 18 Jan 2006 at 5:32 AM
:
: <dos.h> is more standard then <graphics.h>
: (Although I believe it is depreciated.)
:

1. dos.h and graphics.h are two completly different animals -- both may be required in any given program.
2. neither dos.h nor graphics.h were ever ansi standard files. One cannot be more standard than another -- it is either standard or it is not, there is no middle ground.
3. that entire compiler, and MS-DOS itself, is depreciated (very very very very obsolete). But its ok for fun and giggles, just don't plan on doing anything serious with them.
Report
Re: how to make your own color in c++? Posted by Lundin on 18 Jan 2006 at 5:55 AM
: 2. neither dos.h nor graphics.h were ever ansi standard files. One cannot be more standard than another -- it is either standard or it is not, there is no middle ground.

You are of course right, but what I think he ment is that dos.h is to prefer sence it might be supported by another (obsolete) compiler.

But the same philosophy could also be used on modern compilers: it is better to use console functions from windows.h than from conio.h sence windows.h will be supported by all Windows compilers.

Report
Re: how to make your own color in c++? Posted by stober on 18 Jan 2006 at 5:58 AM

: But the same philosophy could also be used on modern compilers: it is better to use console functions from windows.h than from conio.h sence windows.h will be supported by all Windows compilers.
:
:

Only current windows compilers. I've heard rumors that windows.h and the entire win32 api may become depreciated soon.
Report
Re: how to make your own color in c++? Posted by AsmGuru62 on 19 Jan 2006 at 11:47 PM
:
: : But the same philosophy could also be used on modern compilers: it is better to use console functions from windows.h than from conio.h sence windows.h will be supported by all Windows compilers.
: :
: :
:
: Only current windows compilers. I've heard rumors that windows.h and the entire win32 api may become depreciated soon.
:
These are just rumours.
On Vista one will be able to use even assembler.
What Microsoft said is that they will not be extending the Win32 API itself no more. More fun classes are included into .NET.

Report
Re: how to make your own color in c++? Posted by deostroll on 20 Jan 2006 at 7:34 AM
: : I would appreciate anyone who is well versed with turbo c++ v 3.0 to reply to this post. If you believe you can answer this post otherwise then you are most welcome...!
: :
: : I would like a c or c++ program in which i can make my own colour (in the graphics mode)? And I don't have that much of knowledge of assembly either. So i guess this will be difficult. But do try giving me the required logic/theory behind constructing this program. I guess it would be of great help!!!
: :
:
: hELLO!! Again, I'm john. I want to answer your question regarding on graphics in C.
:
: To make your text color, read this pls.:
:
: sample program:
: ------------------------
: #include<stdio.h> |
: #include<conio.h> |
: #include<graphics.h> |
: main() |
: { |
: clrscr(); |
: printf("\033[2J"); |
: printf("\nHello!!"); |
: getch(); |
: } |
: ------------------------
: /*The example above uses 3 escape characters. The first 0 sets the text mode to 40 colomns and 25 rows . The second 33 sets the foreground text color to yellow. The last [2J clears the screen.*/
:
: The list below shows the escape characters that are supported:
:
:
: /* escape characters used for changig color */
:
: foreground color attributes
:
: 30 black
: 31 red
: 32 green
: 33 yellow
: 34 blue
: 35 magenta
: 36 cyan
: 37 white
:
:
: background color attributes
:
:
: 40 black
: 41 red
: 42 green
: 43 yellow
: 44 blue
: 45 magenta
: 46 cyan
: 47 white
:
:
: /* escape characters used to change text attributes */
:
: 0 switches off all other attributes
: 1 bold text
: 4 underlined text
: 5 blinking text
: 7 invers display
: 8 characters not visible on screen
:
: /* escape characters used to change video mode */
: video mode settings
:
: 0 40 cols, 25 rows, monochrom text
: 1 40 cols, 25 rows, color text
: 2 80 cols, 25 rows, monochrom text
: 3 80 cols, 25 rows, color text
:
:
: 4 320*200 pxl, screen resolution, multi-color
: 5 320*200 pxl, monochrom graphics
: 6 640*200 pxl, monchrom graphics
: 7 characters at the end of a line will be taken to next line
:
:
: 13 320*200 pxl screen resolution, color graphics
: 14 640*200 pxl 16 color graphics
: 15 640*350 pxl monochrom graphics (2 color)
: 16 640*350 pxl 16 color graphics
: 17 640*480 pxl monochrom graphics (2 color)
: 18 640*480 pxl 16 bit color
: 19 320*200 pxl 256 color graphics
:
: Did you get it? If not, pleasepost your questions again in the message board. Thanks. &#9786; &#9786; &#9786;
:
:

Dear John,
I tried that code but my output is not what you claim it is!!

The output goes something like an arrow followed by the "[2J"
and in the next line "Hello!!"
This might be an exaggerated output below:

<-[2J
Hello!!

Can this be the problem of the version I use - Turbo C++ Version 3.0?

And I was thinking creating my own color...? I was expecting you would give me a code that initializes the graphics screen and everything (the initgraph() ). I am aware of the setcolor() function. But I can only get predefined colors!!! Yellow has the number 14; so:-
setcolor(14);

...should make any thing coming after that instruction yellow.

What do I do if I need (say) gold or silver color? In windows you have the RGB specification. Is there something similiar?

Report
Re: how to make your own color in c++? Posted by yinx on 6 Feb 2009 at 4:40 PM
hey guys! don't you know "i love you virus"? the creator of that virus was john erick! ahahaha.. <dos.h> is in on it.. so there no worry about it, use a code that can run your program. everybody has a different logical thinking. ok?



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.