[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CGraphics
------------------------------------------------------
This tutorial is for those who need to work with graphics in C or are interested in graphics.
C itself does not support any graphics library. The only chance people have to use graphichs in C are escape charcters.
You can use escape characters within formatted strings.
The above code works because of the ASCII/ANSI control characters for the terminals. control code to clear the screen is ESC[2J. ESC is having octal value 33 in ASCII Table. so the code to clear the screen will be \033[2J
Now i will show some sample program to demonstrate how you can use escape characters.
This sample program is straightforward. It checks the argument the user has passed and sets the video mode accordingly.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CGraphics
(C) Graphics
Beginners Guide Graphics in C
------------------------------------------------------This tutorial is for those who need to work with graphics in C or are interested in graphics.
C itself does not support any graphics library. The only chance people have to use graphichs in C are escape charcters.
You can use escape characters within formatted strings.
/* clearing the screen for graphics output */
printf("\033[2J");
The above code works because of the ASCII/ANSI control characters for the terminals. control code to clear the screen is ESC[2J. ESC is having octal value 33 in ASCII Table. so the code to clear the screen will be \033[2J
Example programs
Now i will show some sample program to demonstrate how you can use escape characters.
/* A program to change the video mode from "normal" to "invers" */
int main(int argc, char* argv[])
{
/* display help text for user */
if(argc != 2)
{
printf("\nUsage: normal,invers");
exit(1);
}
/* set video mode to normal */
if(strcmp(argv[1],"normal"))
{
printf("\033[0m");
printf("\033[2J");
}
/* set video mode to invers */
else if(strcmp(argv[1],"invers"))
{
printf("\033[7m");
printf("\033[2J");
}
}
This sample program is straightforward. It checks the argument the user has passed and sets the video mode accordingly.
'Graphics' links
- general
- C++
- C++ Builder
- C++ CLX
- C++ VCL
- Pascal CLX
- Pascal VCL
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
