Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // (a)Study and enlist the basic functions used for
- // graphics in C/C++/Python language .Give an example
- // for each of them.
- // (i)arc():
- #include<graphics.h>
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- int gd=DETECT,gm;
- initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
- arc(100,100,0,35,50);
- getch();
- closegraph();
- }
- //(ii)bar() and bar3d():
- #include<graphics.h>
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- int gd=DETECT,gm;
- initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
- bar(100,100,200,200);
- bar3d(250,250,300,300,20,1);
- getch();
- closegraph();
- }
- //(iii)circle():
- #include<graphics.h>
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- int gd=DETECT,gm;
- initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
- circle(100,100,50);
- getch();
- closegraph();
- }
- //(iv)cleardevice():
- #include<graphics.h>
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- int gd=DETECT,gm;
- initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
- circle(100,100,50);
- outtext("Press any key to clear the screen");
- getch();
- cleardevice();
- outtext("Press any key to exit");
- getch();
- closegraph();
- }
- //v)drawpoly():
- #include<graphics.h>
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- int gd=DETECT,gm,points[]={520,150,420,300,250,300,520,150};
- initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
- drawpoly(4,points);
- getch();
- closegraph();
- }
- //(vi)fillpoly():
- #include<graphics.h>
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- int gd=DETECT,gm,points[]={520,150,420,300,250,300,520,150};
- initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
- fillpoly(4,points);
- getch();
- closegraph();
- }
- //(vii)ellipse() and fillellipse():
- #include<graphics.h>
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- int gd=DETECT,gm;
- initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
- ellipse(100,100,0,360,50,25);
- fillellipse(300,200,150,75);
- getch();
- closegraph();
- }
- //(viii)floodfill():
- #include<graphics.h>
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- int gd=DETECT,gm;
- initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
- setcolor(RED);
- circle(100,100,50);
- floodfill(100,100,RED);
- getch();
- closegraph();
- }
- //(ix)getmaxx() and getmaxy():
- #include <graphics.h>
- #include <stdio.h>
- #include <conio.h>
- void main()
- {
- int gd = DETECT, gm, max_x, max_y;
- char array[100];
- initgraph(&gd, &gm, "C:\\TurboC3\\BGI");
- max_x = getmaxx();
- printf("Maximum x co-ordinates for current graphics mode and driver =
- %d\n",max_x);
- max_y=getmaxy();
- printf("Maximum y co-ordinates for current graphics mode and driver =
- %d",max_y);
- outtext(array);
- getch();
- closegraph();
- }
- //(x)getpixel():
- #include<graphics.h>
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- int gd=DETECT,gm,color;
- initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
- color=getpixel(0,0);
- printf("Color of pixel at (0,0) = %d",color);
- getch();
- closegraph();
- }
- //(xi)getx() and gety():
- #include<graphics.h>
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- int gd=DETECT,gm;
- initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
- printf("Current position of x = %d\n",getx());
- printf("Current position of y = %d",gety());
- getch();
- closegraph();
- }
- //(xiii)putpixel():
- #include<graphics.h>
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- int gd=DETECT,gm;
- initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
- putpixel(25,25,WHITE);
- getch();
- closegraph();
- }
- //(xiii)putpixel():
- #include<graphics.h>
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- int gd=DETECT,gm;
- initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
- putpixel(25,25,WHITE);
- getch();
- closegraph();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement