ellipse() Function in C Graphics – Syntax and Example
Introduction to ellipse() Function
The ellipse() function is used to draw an ellipse on the graphics screen. An ellipse is an oval-shaped figure. The function requires six parameters: the X-coordinate and Y-coordinate of the centre, the starting angle, the ending angle, the horizontal radius and the vertical radius. The ellipse() function is available in the traditional BGI (Borland Graphics Interface) graphics library through the graphics.h header file.
ellipse() फंक्शन का उपयोग ग्राफिक्स स्क्रीन पर दीर्घवृत्त (Ellipse) बनाने के लिए किया जाता है। दीर्घवृत्त एक अंडाकार आकृति होती है। इस फंक्शन में छह पैरामीटर होते हैं: केंद्र का X-coordinate, केंद्र का Y-coordinate, प्रारंभिक कोण, अंतिम कोण, क्षैतिज त्रिज्या तथा ऊर्ध्वाधर त्रिज्या। ellipse() फंक्शन पारंपरिक BGI (Borland Graphics Interface) ग्राफिक्स लाइब्रेरी में उपलब्ध होता है, जिसके लिए graphics.h हेडर फाइल का उपयोग किया जाता है।
Syntax of ellipse() Function
void ellipse(int x, int y, int startAngle,int endAngle, int xRadius, int yRadius);
Parameters:
x: X-coordinate of the centre of the ellipse.y: Y-coordinate of the centre of the ellipse.startAngle: Starting angle of the ellipse.endAngle: Ending angle of the ellipse.xRadius: Horizontal radius of the ellipse.yRadius: Vertical radius of the ellipse.
पैरामीटर्स:
x: दीर्घवृत्त के केंद्र का X-coordinate।y: दीर्घवृत्त के केंद्र का Y-coordinate।startAngle: दीर्घवृत्त का प्रारंभिक कोण।endAngle: दीर्घवृत्त का अंतिम कोण।xRadius: दीर्घवृत्त की क्षैतिज त्रिज्या।yRadius: दीर्घवृत्त की ऊर्ध्वाधर त्रिज्या।
Example: C Program to Draw an Ellipse Using ellipse() Function
The following program demonstrates how to draw a complete ellipse with its centre at (250, 200), horizontal radius of 120 and vertical radius of 60.
निम्न प्रोग्राम में (250, 200) को दीर्घवृत्त का केंद्र, 120 को क्षैतिज त्रिज्या तथा 60 को ऊर्ध्वाधर त्रिज्या मानकर एक पूरा दीर्घवृत्त बनाया गया है।
#include <graphics.h>#include <conio.h>int main(void){int gd = DETECT, gm;initgraph(&gd, &gm, "C:\\TC\\BGI");ellipse(250, 200, 0, 360, 120, 60);getch();closegraph();return 0;}
Output:
A graphics window appears showing a complete oval-shaped ellipse with its centre at (250, 200).
ग्राफिक्स विंडो में (250, 200) केंद्र वाला एक पूरा अंडाकार दीर्घवृत्त दिखाई देगा।
Difference Between circle() and ellipse() Functions
| circle() | ellipse() |
|---|---|
| Draws a circle. | Draws an ellipse. |
| Requires 3 parameters. | Requires 6 parameters. |
| Uses one radius. | Uses horizontal and vertical radii. |
| Both radii are equal in a circle. | The two radii can be different. |
circle() | ellipse() |
|---|---|
| वृत्त बनाता है। | दीर्घवृत्त बनाता है। |
| इसमें 3 पैरामीटर होते हैं। | इसमें 6 पैरामीटर होते हैं। |
| इसमें एक त्रिज्या का उपयोग होता है। | इसमें क्षैतिज और ऊर्ध्वाधर त्रिज्या होती हैं। |
| वृत्त में दोनों दिशाओं की त्रिज्या समान होती है। | दीर्घवृत्त में दोनों दिशाओं की त्रिज्या अलग-अलग हो सकती हैं। |
Important Points About ellipse() Function
The
ellipse()function can draw a complete ellipse or a portion of an ellipse depending on the starting and ending angles.ellipse()फंक्शन प्रारंभिक और अंतिम कोणों के आधार पर पूरा दीर्घवृत्त या उसका कोई भाग बना सकता है।The
xRadiusdetermines the horizontal size of the ellipse.xRadiusदीर्घवृत्त का क्षैतिज आकार निर्धारित करता है।The
yRadiusdetermines the vertical size of the ellipse.yRadiusदीर्घवृत्त का ऊर्ध्वाधर आकार निर्धारित करता है।When both radii are equal, the ellipse becomes a circle.
जब दोनों त्रिज्याएँ समान होती हैं, तब दीर्घवृत्त एक वृत्त बन जाता है।
The
ellipse()function draws only the outline and does not automatically fill the shape with color.ellipse()फंक्शन केवल बाहरी सीमा बनाता है और अपने आप आकृति में रंग नहीं भरता है।The
ellipse()function belongs to the BGI graphics library and is not a standard C function.ellipse()फंक्शन 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(), ellipse() and closegraph() are not provided by standard C compilers such as GCC by default.
ऊपर दिया गया प्रोग्राम पारंपरिक Turbo C/BGI ग्राफिक्स वातावरण के लिए है। graphics.h लाइब्रेरी तथा initgraph(), ellipse() और closegraph() जैसे फंक्शन GCC जैसे आधुनिक C कंपाइलर में डिफॉल्ट रूप से उपलब्ध नहीं होते हैं।
Comments
Post a Comment