C में Shapes बनाना
In this page:
circle(x, y, radius);
rectangle(left, top, right, bottom);
ellipse(x, y, start_angle, end_angle, x_radius, y_radius);
Circles Draw करना
circle() एक center coordinate (X, Y) और pixels में एक radius देखकर एक wireframe circle outline draw करता है, सिर्फ boundary trace करते हुए interior fill किए बिना — एक solid disc के लिए आप equal horizontal और vertical radii के साथ इसकी बजाय fillellipse() इस्तेमाल करेंगे।
उदाहरण: Drawing Circles
#include <graphics.h>
int main() {
initgraph(0, 0, "");
circle(150, 150, 50);
getch();
closegraph();
return 0;
}
Login to try C/C++/Java/PHP code in the editor
Rectangles Draw करना
rectangle() चार coordinates से एक outlined box draw करता है: top-left corner का X और Y, फिर bottom-right corner का X और Y, इसलिए function खुद उन दो corner points के बीच की distance से width और height compute करता है, उन्हें सीधे लेने की बजाय।
उदाहरण: Drawing Rectangles
#include <graphics.h>
int main() {
initgraph(0, 0, "");
rectangle(50, 50, 200, 150);
getch();
closegraph();
return 0;
}
Login to try C/C++/Java/PHP code in the editor
Ellipses Draw करना
ellipse() एक elliptical arc draw करता है और total आठ parameters लेता है: center coordinates, degrees में एक start और end angle (आपको एक full ellipse की बजाय एक partial arc draw करने देते हुए), और अलग horizontal और vertical radii, जो इसे सिर्फ perfect circles की बजाय true ellipses draw करने देता है।
उदाहरण: Drawing Ellipses
#include <graphics.h>
int main() {
initgraph(0, 0, "");
ellipse(150, 150, 0, 360, 80, 40);
getch();
closegraph();
return 0;
}
Login to try C/C++/Java/PHP code in the editor
Filled Shapes
fillellipse() और bar() outlines की बजाय solid, filled shapes draw करते हैं — fillellipse() एक elliptical region भरता है, जबकि bar() एक rectangular fill करता है, और bar3d() visible side faces वाले एक pseudo-3D block render करने के लिए एक extra depth parameter से bar() को extend करता है।
उदाहरण: Filled Shapes
#include <graphics.h>
int main() {
initgraph(0, 0, "");
fillellipse(150, 150, 60, 40);
bar(50, 50, 150, 100);
getch();
closegraph();
return 0;
}
Login to try C/C++/Java/PHP code in the editor
Polygons Draw करना
drawpoly() और fillpoly() दोनों vertices की तरह आपके दिए (X, Y) coordinate pairs के एक array से arbitrary multi-sided shapes draw करते हैं, drawpoly() सिर्फ polygon का outline trace करता है और fillpoly() additionally इसके interior को current fill style से भरता है।
उदाहरण: Drawing Polygons
#include <graphics.h>
int main() {
initgraph(0, 0, "");
int points[6] = {100, 50, 150, 150, 50, 150};
drawpoly(3, points);
getch();
closegraph();
return 0;
}
Login to try C/C++/Java/PHP code in the editor
initgraphcall करने से पहले shapes draw करना, ताकि कुछ न दिखे।rectangle(left, top, right, bottom)में arguments का order मिला देना, जो एक गलत या empty shape देता है।- यह उम्मीद करना कि
circle(x, y, r)filled होगा, जब यह सिर्फ एक outline draw करता है जब तक आपfloodfillया एक fill style भी इस्तेमाल न करें।
Chapter Quiz — Complete all 10 topics to unlock
0/10 topics done
Complete these topics first: