Академический Документы
Профессиональный Документы
Культура Документы
BY ANURAG
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
#include<graphics.h>
void main()
int a=DETECT,b=DETECT;
initgraph(&a,&b,"");
setcolor(4);
line(10,10,300,300);
/* ARC,CIRCLE,PIE
*þ arc draws a circular arc
Declaration:
þ void far arc(int x, int y, int stangle, int endangle, int radius);
þ void far pieslice(int x, int y, int stangle, int endangle, int radius);*/
arc(100,100,30,250,50);
circle(300,300,50);
pieslice(200,200,30,250,50);
/*BAR
Draws a bar
Declaration: void far bar(int left, int top, int right, int bottom); */
bar(50,70,70,300);
/*BAR3Dd
Draws a 3-D bar
Declaration: void far bar3d(int left, int top, int right, int bottom,
bar3d(50,70,70,300,((50+70)/2),1);
/*CLEARSCREEN
Clears the graphics screen
CLEARVIEWPORT
Clears the current viewport
Remarks:
clearviewport erases the viewport and moves the CP (current position) to home (0,0), relative to the
viewport.
CLOSEGRAPH
Shuts down the graphics system
Remarks:
closegraph deallocates all memory allocated by the graphics system.It then restores the screen to the
mode it was in before you called
initgraph.
DETECTGRAPH
Determines graphics driver and mode to use by checking the hardware.
Declaration:
Remarks:
detectgraph detects your system's graphics adapter and chooses the mode that
DRAWPOLY,FILLPOLY
þ drawpoly draws the outline of a polygon
Declaration:
Remarks:
drawpoly draws a polygon using the current line style and color.
fillpoly draws the outline of a polygon using the current line style and
color, then fills the polygon using the current fill pattern and fill color.
ELLIPSE,FILLELLIPSE,SECTOR
þ ellipse draws an elliptical arc
Declaration:
þ void far ellipse(int x, int y, int stangle, int endangle,
Remarks:
fillellipse draws an ellipse, then fills the ellipse with the current fill
sector draws and fills an elliptical pie slice in the current drawing color,
setfillpattern.
*/
ellipse(250,250,0,180,50,70);
fillellipse(500,350,70,50);
sector(200,400,0,180,50,70);
/*FLOODFILL
Flood-fills a bounded region
Remarks:
The area bounded by the color border is flooded with the current fill
Declaration:
Remarks:
setaspectratio(500,300);
/*
SETBACKGROUNDCOLOR,GETBACKGROUNDCOLOR
þ getbkcolor returns the current background color
Declaration:
Remarks:
setbkcolor(2);
/*GETCOLOR,SETCOLOR
þ getcolor returns the current drawing color
Remarks:
setcolor sets the current drawing color to color, which can range from 0 to
getmaxcolor.*/
setcolor(4);
Declaration:
Remarks:
/*GETIMAGE,PUTSETIMAGE
þ getimage saves a bit image of the specified region into memory
Declaration:
þ void far getimage(int left, int top, int right, int bottom,
þ void far putimage(int left, int top, void far *bitmap, int op);
Remarks:
þ putimage puts the bit image previously saved with getimage back onto the
screen, with the upper left corner of the image placed at (left,top).
GETMAXX,GETMAXY
Returns maximum x or y screen coordinate
Declaration:
Remarks:
GETPIXEL,PUTPIXEL
þ getpixel gets the color of a specified pixel
Declaration:
Remarks:
*/
putpixel(500,700,4);
getpixel(500,700);
/* TEXTSETTINGS
Gets information about the current graphic text font
Declaration:
Remarks:
Declaration:
Remarks:
INITGRAPH
Initializes the graphics system
Declaration:
Remarks:
To start the graphics system, you must first call initgraph.
disk (or validating a registered driver) then putting the system into
graphics mode.
LINE,LINEREL,LINETO
þ line draws a line between two specified points
þ linerel draws a line a relative distance from the current position (CP)
Declaration:
þ void far line(int x1, int y1, int x2, int y2);
Remarks:
þ line draws a line from (x1, y1) to (x2, y2) using the current color, line
style, and thickness. It does not update the current position (CP).
(dx, dy) from the CP, then advances the CP by (dx, dy).
þ lineto draws a line from the CP to (x, y), then moves the CP to (x, y).
*/
line(100,100,700,700);
linerel(50,90);
lineto(200,700);
/*MOVREL,MOVETO
þ moverel moves the current position (CP) a relative distance
Remarks:
þ moverel moves the current position (CP) dx pixels in the x direction and
þ moveto moves the current position (CP) to viewport position (x, y).*/
moveto(0,0);
/*OUTTEXT,OUTTEXTXY
þ outtext displays a string in the viewport (graphics mode)
Declaration:
Remarks:
outtext and outtextxy display a text string, using the current justification
outtext("anurag kumar");
outtextxy(300,300,"Anurag Kumar");
/*RECTANGLE
Draws a rectangle (graphics mode)
Declaration:
void far rectangle(int left, int top, int right, int bottom);
Remarks:
drawing color.*/
rectangle(200,200,300,400);
/*SETFILLSTYLE
Sets the fill pattern and color
Remarks:
SETLINESTYLE
Sets the current line style and width or pattern
Declaration:
Remarks:
setlinestyle sets the style for all lines drawn by line, lineto, rectangle,
drawpoly, etc.
*/
setlinestyle(2,2,1000);
line(10,10,600,600);
/*SETTEXTJUSTIFY
Sets text justification for graphics mode
SETTEXTSTYLE
Sets the current text characteristics
Declaration:
Remarks:
settextstyle sets the text font, the direction in which text is displayed,
SETUSERCHARSIZE
User-defined character magnification factor for stroked fonts
Declaration:
void far setusercharsize(int multx, int divx, int multy, int divy);
Remarks:
setusercharsize gives you finer control over the size of text from stroked
GLITTERING SKY
while(!kbhit())
{
delay(40);
putpixel(random(640),random(248),random(15));
getch();