A function in Borland's graphics library in TurboC; switches to graphics mode.
Platform-dependent. For Turbo C, enter initgraph and press Ctrl+F1.
because initgraph() automatically detect current available graphmode and load it on to the graphdriver.
Initgraph initializes the graphics system by loading a graphics driver from disk (or validating a registered driver) then putting the system into graphics mode.Initgraph also resets all graphics settings (color, palette, current position, viewport, etc.) to their defaults, then resets graphresult to 0.
At the beginning in the header file: #include <graphics.h>
To draw a rectangle in Turbo Pascal, you can use the Rectangle procedure from the Graph unit. First, initialize the graphics mode with InitGraph, then specify the coordinates for the top-left and bottom-right corners of the rectangle. Use the Rectangle function with these coordinates, and finally, use CloseGraph to exit the graphics mode. Here’s a simple example: uses Graph; var gd, gm: Integer; begin gd := Detect; InitGraph(gd, gm, ''); Rectangle(100, 100, 300, 200); // Draws a rectangle ReadLn; // Wait for user input CloseGraph; end.
The initgraph() is a method that you always use when you want to write graphic programming in C++. It is used to initial graphi window before something can be drawn on the window.
Platform-dependent. For Turbo C, enter initgraph and press Ctrl+F1.
because initgraph() automatically detect current available graphmode and load it on to the graphdriver.
Initgraph initializes the graphics system by loading a graphics driver from disk (or validating a registered driver) then putting the system into graphics mode.Initgraph also resets all graphics settings (color, palette, current position, viewport, etc.) to their defaults, then resets graphresult to 0.
At the beginning in the header file: #include <graphics.h>
To draw a rectangle in Turbo Pascal, you can use the Rectangle procedure from the Graph unit. First, initialize the graphics mode with InitGraph, then specify the coordinates for the top-left and bottom-right corners of the rectangle. Use the Rectangle function with these coordinates, and finally, use CloseGraph to exit the graphics mode. Here’s a simple example: uses Graph; var gd, gm: Integer; begin gd := Detect; InitGraph(gd, gm, ''); Rectangle(100, 100, 300, 200); // Draws a rectangle ReadLn; // Wait for user input CloseGraph; end.
BGI stands for Borland Graphics Interface. These are the files that contains the information about the graphic functions to be used. These are responsible for performing graphic operations under dos. In Borland turbo c++ these files are contained in directory. -> c:\tc\bgi By default these are loaded in the current directory while compiling and executing the program under c/c++ but sometimes we need to specify their path in "initgraph() function. like: initgrapy(&gdriver,&gmode,"c:\\tc\\bgi"); otherwise it will display you error about bgi.
To draw a rectangle in Dev-C++, you can use the graphics.h library, which provides functions for drawing shapes. First, include the graphics.h header and initialize the graphics mode using initgraph(). Then, use the rectangle(x1, y1, x2, y2) function, where (x1, y1) are the coordinates of one corner and (x2, y2) are the coordinates of the opposite corner. Finally, use getch() to wait for a key press before closing the graphics window with closegraph().
Here, maybe a few other shapes as well#include#includevoid main(){int gd=DETECT, gm;int poly[12]={350,450, 350,410, 430,400, 350,350, 300,430, 350,450 };initgraph(&gd, &gm, "");circle(100,100,50);outtextxy(75,170, "Circle");rectangle(200,50,350,150);outtextxy(240, 170, "Rectangle");ellipse(500, 100,0,360, 100,50);outtextxy(480, 170, "Ellipse");line(100,250,540,250);outtextxy(300,260,"Line");sector(150, 400, 30, 300, 100,50);outtextxy(120, 460, "Sector");drawpoly(6, poly);outtextxy(340, 460, "Polygon");getch();closegraph();}
#include#include#includevoid main(){int gd=DETECT,gm=4,i;initgraph(&gd,&gm,"c:\\tc\\bgi");setcolor(3);for(i=0;i
int main() { int gd = DETECT, gm; int midx, midy; initgraph(&gd, &gm, "C:\TC\BGI"); setcolor(MAGENTA); rectangle(0,40,639,450); settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2); setcolor(WHITE); outtextxy(275,10,"Pie Chart"); midx = getmaxx()/2; midy = getmaxy()/2; setfillstyle(LINE_FILL,BLUE); pieslice(midx, midy, 0, 75, 100); outtextxy(midx+100, midy - 75, "20.83%"); setfillstyle(XHATCH_FILL,RED); pieslice(midx, midy, 75, 225, 100); outtextxy(midx-175, midy - 75, "41.67%"); setfillstyle(WIDE_DOT_FILL,GREEN); pieslice(midx, midy, 225, 360, 100); outtextxy(midx+75, midy + 75, "37.50%"); getch(); return 0; }
: #include<graphics.h> #include<stdio.h> #include<conio.h> #include<alloc.h> #include<math.h> #include<dos.h> const pi=3.14; void main() {int gd=DETECT, gm,i,x,y; int size; void *buf; initgraph(&gd,&gm,"c:\\tc\\bgi"); ellipse(240,210,0,160,90,45); ellipse(240,190,180,360,90,45); circle(170,195,3); ellipse(100,230,10,400,100,80); ellipse(232,207,0,365,100,150); arc(265,170,0,160,15); arc(225,233,180,350,20); arc(265,233,180,380,10); size=imagesize(150,150,350,350); buf=(char *)malloc(size); getimage(150,150,350,350,buf); for(i=0;i<=360;i+=2) {delay(10); cleardevice(); x=150*cos(i*pi/180); y=150*sin(i*pi/180); putimage(200+x,100+y,buf,0); } getch(); restorecrtmode();}