arc() Function in C Graphics – Syntax and Example
Introduction to arc() Function
The arc() function is used to draw a part of a circle (circular arc) on the graphics screen. It requires five parameters: the X-coordinate of the centre, the Y-coordinate of the centre, the starting angle, the ending angle and the radius of the arc. The arc() function is available in the traditional BGI (Borland Graphics Interface) graphics library through the graphics.h header file.
arc() फंक्शन का उपयोग ग्राफिक्स स्क्रीन पर वृत्त के किसी भाग अर्थात चाप (Circular Arc) को बनाने के लिए किया जाता है। इसमें पाँच पैरामीटर होते हैं: केंद्र का X-coordinate, केंद्र का Y-coordinate, प्रारंभिक कोण (Starting Angle), अंतिम कोण (Ending Angle) तथा चाप की त्रिज्या (Radius)। arc() फंक्शन पारंपरिक BGI (Borland Graphics Interface) ग्राफिक्स लाइब्रेरी में उपलब्ध होता है, जिसके लिए graphics.h हेडर फाइल का उपयोग किया जाता है।
Syntax of arc() Function
void arc(int x, int y, int startAngle, int endAngle, int radius);Parameters:
x: X-coordinate of the centre of the arc.y: Y-coordinate of the centre of the arc.startAngle: Starting angle of the arc in degrees.endAngle: Ending angle of the arc in degrees.radius: Radius of the arc.
पैरामीटर्स:
x: चाप के केंद्र का X-coordinate।y: चाप के केंद्र का Y-coordinate।startAngle: चाप का प्रारंभिक कोण (डिग्री में)।endAngle: चाप का अंतिम कोण (डिग्री में)।radius: चाप की त्रिज्या।
Understanding Angles in arc() Function
In BGI graphics, angles are measured in degrees. The angle 0° is at the right side of the centre, 90° is at the top, 180° is at the left and 270° is at the bottom. For example, arc(200, 200, 0, 180, 100) draws the upper half of a circle with its centre at (200, 200) and radius 100.
BGI ग्राफिक्स में कोणों को डिग्री में मापा जाता है। 0° केंद्र के दाईं ओर, 90° ऊपर, 180° बाईं ओर तथा 270° नीचे की दिशा में होता है। उदाहरण के लिए, arc(200, 200, 0, 180, 100) फंक्शन (200, 200) केंद्र तथा 100 त्रिज्या वाले वृत्त का ऊपरी आधा भाग बनाता है।
Example: C Program to Draw an Arc Using arc() Function
The following program demonstrates how to draw an arc from 0 degrees to 180 degrees.
निम्न प्रोग्राम में arc() फंक्शन की सहायता से 0 डिग्री से 180 डिग्री तक का चाप बनाया गया है।
#include <graphics.h>#include <conio.h>int main(void){int gd = DETECT, gm;initgraph(&gd, &gm, "C:\\TC\\BGI");arc(200, 200, 0, 180, 100);getch();closegraph();return 0;}
Output:
A graphics window appears showing the upper half of a circle with its centre at (200, 200) and radius of 100 pixels.
ग्राफिक्स विंडो में (200, 200) केंद्र तथा 100 पिक्सेल त्रिज्या वाले वृत्त का ऊपरी आधा भाग दिखाई देगा।
Important Points About arc() Function
The
arc()function draws a portion of a circle, not a complete circle.arc()फंक्शन पूरे वृत्त के बजाय उसके किसी एक भाग को बनाता है।The starting and ending angles determine which portion of the circle is drawn.
प्रारंभिक और अंतिम कोण यह निर्धारित करते हैं कि वृत्त का कौन-सा भाग बनाया जाएगा।
Angles are specified in degrees, generally from 0 to 360.
कोणों को डिग्री में दिया जाता है, सामान्यतः 0 से 360 तक।
The radius determines the size of the arc.
त्रिज्या चाप का आकार निर्धारित करती है।
The
arc()function draws only the arc outline; it does not fill the enclosed region with color.arc()फंक्शन केवल चाप की बाहरी रेखा बनाता है। यह उसके अंदर के क्षेत्र में रंग नहीं भरता है।The
arc()function belongs to the BGI graphics library and is not a standard C function.arc()फंक्शन BGI ग्राफिक्स लाइब्रेरी का हिस्सा है, यह Standard C का फंक्शन नहीं है।
Note for Modern C Compilers
The above program is written for the traditional Turbo C/BGI graphics environment. The graphics.h library and functions such as initgraph(), arc() and closegraph() are not provided by standard C compilers such as GCC by default.
ऊपर दिया गया प्रोग्राम पारंपरिक Turbo C/BGI ग्राफिक्स वातावरण के लिए है। graphics.h लाइब्रेरी तथा initgraph(), arc() और closegraph() जैसे फंक्शन GCC जैसे आधुनिक C कंपाइलर में डिफॉल्ट रूप से उपलब्ध नहीं होते हैं।
Comments
Post a Comment