C Graphics परिचय
In this page:
C में Graphics क्या है?
Computer screens दो modes में operate करती हैं: text mode और graphics mode। Standard console programs text mode इस्तेमाल करते हैं। Graphics mode आपको screen पर individual pixels control करके shapes, lines, और custom colors draw करने देता है।
Traditional C graphics graphics.h library के जरिए BGI (Borland Graphics Interface) इस्तेमाल करता है, जो computer graphics basics सीखने के लिए classic है।
उदाहरण: What is Graphics in C?
#include <graphics.h>
int main() {
initgraph(0, 0, "");
putpixel(100, 100, WHITE);
getch();
closegraph();
return 0;
}
Login to try C/C++/Java/PHP code in the editor
Graphics Coordinate System
C graphics में, screen pixels का एक grid है। Top-left corner origin point (0, 0) है। X-coordinate right की ओर बढ़ता है। Y-coordinate नीचे की ओर बढ़ता है। यह normal cartesian coordinates से अलग है जहाँ Y ऊपर जाता है।
उदाहरण: The Graphics Coordinate System
#include <graphics.h>
int main() {
initgraph(0, 0, "");
putpixel(0, 0, WHITE);
getch();
closegraph();
return 0;
}
Login to try C/C++/Java/PHP code in the editor
Compilation Requirements
modern systems पर graphics.h code चलाने के लिए, आपको DOSBox जैसे एक emulator या Turbo C++ जैसे एक compatible setup की ज़रूरत है। Alternatively, आप winbgim या SDL2 जैसी modern libraries इस्तेमाल कर सकते हैं जो modern GCC configurations के under compile हो सकती हैं।
उदाहरण: Compilation Requirements
#include <graphics.h>
int main() {
initgraph(0, 0, "");
getch();
closegraph();
return 0;
}
Login to try C/C++/Java/PHP code in the editor
वापस Text Mode में Switch करना
जब आपकी drawing processes पूरी हो जाएं, आपको graphics system shut down करना होगा। closegraph() function graphics drivers unload करता है और console को वापस standard text mode में restore करता है।
उदाहरण: Switching Back to Text Mode
#include <graphics.h>
int main() {
initgraph(0, 0, "");
putpixel(50, 50, WHITE);
getch();
closegraph();
return 0;
}
Login to try C/C++/Java/PHP code in the editor
Basic Graphic Concepts
एक digital screen की fundamental unit pixel है। Graphics mode में, आप individual pixels की state बदल सकते हैं या कई pixels से बने complex shapes draw कर सकते हैं।
Coordinates और screen buffers की एक basic समझ fluid graphics output बनाने में मदद करती है।
उदाहरण: Basic Graphic Concepts
#include <graphics.h>
int main() {
initgraph(0, 0, "");
putpixel(10, 10, WHITE);
getch();
closegraph();
return 0;
}
Login to try C/C++/Java/PHP code in the editor
graphics.hको standard C का हिस्सा मानना, जब यह एक Turbo C / BGI library है जो ज़्यादातर modern compilers include नहीं करते।- अंत में
closegraph()call करना भूल जाना, ताकि graphics window या mode खुली रह जाए। - यह मान लेना कि origin (0, 0) maths की तरह bottom-left पर है, जब यह top-left corner है और y नीचे की ओर बढ़ता है।
Chapter Quiz — Complete all 10 topics to unlock
0/10 topics done
Complete these topics first: