← Back to C Course | Chapter 13: Graphics | Lesson 1 of 10

C Graphics परिचय

C में Graphics का मतलब है सिर्फ text की बजाय screen पर pictures draw करना, एक typewriter से एक paintbrush पर जाने जैसा। Positions एक grid पर points की तरह दिए जाते हैं।

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?

c
#include <graphics.h>
int main() {
	initgraph(0, 0, "");
	putpixel(100, 100, WHITE);
	getch();
	closegraph();
	return 0;
}

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

c
#include <graphics.h>
int main() {
	initgraph(0, 0, "");
	putpixel(0, 0, WHITE);
	getch();
	closegraph();
	return 0;
}

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

c
#include <graphics.h>
int main() {
	initgraph(0, 0, "");
	getch();
	closegraph();
	return 0;
}

वापस Text Mode में Switch करना

जब आपकी drawing processes पूरी हो जाएं, आपको graphics system shut down करना होगा। closegraph() function graphics drivers unload करता है और console को वापस standard text mode में restore करता है।

उदाहरण: Switching Back to Text Mode

c
#include <graphics.h>
int main() {
	initgraph(0, 0, "");
	putpixel(50, 50, WHITE);
	getch();
	closegraph();
	return 0;
}

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

c
#include <graphics.h>
int main() {
	initgraph(0, 0, "");
	putpixel(10, 10, WHITE);
	getch();
	closegraph();
	return 0;
}
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. graphics.h को standard C का हिस्सा मानना, जब यह एक Turbo C / BGI library है जो ज़्यादातर modern compilers include नहीं करते।
  2. अंत में closegraph() call करना भूल जाना, ताकि graphics window या mode खुली रह जाए।
  3. यह मान लेना कि origin (0, 0) maths की तरह bottom-left पर है, जब यह top-left corner है और y नीचे की ओर बढ़ता है।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.