putpixel function plots a pixel at location (x, y) of specified color. declaration :- void...
TRANSCRIPT
![Page 1: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/1.jpg)
FUNCTIONS USED IN COMPUTER GRAPHICS
![Page 2: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/2.jpg)
putpixel function plots a pixel at location (x, y) of specified color.
Declaration :- void putpixel(int x, int y, int color);
putpixel function in c
![Page 3: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/3.jpg)
line function is used to draw a line from a point(x1,y1) to point(x2,y2) i.e. (x1,y1) and (x2,y2) are end points of the line.The code given below draws a line.
void line(int x1, int y1, int x2, int y2);
line function in c
![Page 4: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/4.jpg)
#include<graphics.h> #include<conio.h> main() { int gd = DETECT, gm; initgraph(&gd,&gm,"C:\\TC\\BGI"); line(100, 100, 200, 200); getch();}
programming code for line
![Page 5: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/5.jpg)
Declaration :- void circle(int x, int y, int radius);
circle function is used to draw a circle with center (x,y) and third parameter specifies the radius of the circle. The code given below draws a circle.
circle function in c
![Page 6: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/6.jpg)
main() { int gd = DETECT, gm; initgraph(&gd, &gm,"C:\\TC\\BGI"); circle(100, 100, 50); getch();}
C program for circle
![Page 7: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/7.jpg)
Declaration :- void rectangle(int left, int top, int right, int bottom);
rectangle function is used to draw a rectangle. Coordinates of left top and right bottom corner are required to draw the rectangle. left specifies the X-coordinate of top left corner, top specifies the Y-coordinate of top left corner, right specifies the X-coordinate of right bottom corner, bottom specifies the Y-coordinate of right bottom corner. The code given below draws a rectangle.
rectangle function in c
![Page 8: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/8.jpg)
main() { int gd = DETECT, gm; initgraph(&gd, &gm, "C:\\TC\\BGI"); rectangle(100,100,200,200); getch();}
c programming code for rectangle
![Page 9: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/9.jpg)
Declaration :- void arc(int x, int y, int stangle, int endangle, int radius);
arc function is used to draw an arc with center (x,y) and stangle specifies starting angle, endangle specifies the end angle and last parameter specifies the radius of the arc. arc function can also be used to draw a circle but for that starting angle and end angle should be 0 and 360 respectively.
arc function in c
![Page 10: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/10.jpg)
main() { int gd = DETECT, gm; initgraph(&gd, &gm, "C:\\TC\\BGI"); arc(100, 100, 0, 135, 50); getch();}
C programming source code for arc
![Page 11: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/11.jpg)
output
![Page 12: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/12.jpg)
Declarations of ellipse function :-void ellipse(int x, int y, int stangle, int endangle, int xradius, int yradius);
Ellipse is used to draw an ellipse (x,y) are coordinates of center of the ellipse, stangle is the starting angle, end angle is the ending angle, and fifth and sixth parameters specifies the X and Y radius of the ellipse. To draw a complete ellipse strangles and end angle should be 0 and 360 respectively.
ellipse function in c
![Page 13: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/13.jpg)
main() { int gd = DETECT, gm; initgraph(&gd, &gm, "C:\\TC\\BGI"); ellipse(100, 100, 0, 360, 50, 25); getch();}
C programming code for ellipse
![Page 14: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/14.jpg)
output
![Page 15: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/15.jpg)
Declaration of fillellipse function :-void fillellipse(int x, int y, int xradius, int yradius);
x and y are coordinates of center of the ellipse, xradius and yradius are x and y radius of ellipse respectively.
fillellipse function in c
![Page 16: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/16.jpg)
main() { int gd = DETECT, gm; initgraph(&gd, &gm, "C:\\TC\\BGI"); fillellipse(100, 100, 50, 25); getch(); }
C program for fillellipse
![Page 17: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/17.jpg)
output
![Page 18: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/18.jpg)
outtext function displays text at current position.
Declaration :- void outtext(char *string);
outtext function
![Page 19: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/19.jpg)
main() { int gd = DETECT, gm; initgraph(&gd, &gm, "C:\\TC\\BGI"); Outtext(“HELLO WORLD”); getch(); }
C program for outtext
![Page 20: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/20.jpg)
output
![Page 21: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/21.jpg)
outtextxy function display text or string at a specified point(x,y) on the screen.
Declaration :- void outtextxy(int x, int y, char *string);
x, y are coordinates of the point and third argument contains the address of string to be displayed.
outtextxy function in c
![Page 22: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/22.jpg)
main() { int gd = DETECT, gm; initgraph(&gd, &gm, "C:\\TC\\BGI"); Outtextxy(250,350,“HELLO WORLD”); getch(); }
C programming code for outtextxy
![Page 23: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/23.jpg)
output
![Page 24: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/24.jpg)
Declaration :- void setbkcolor(int color); setbkcolor function changes current
background color e.g. setbkcolor(YELLLOW) changes the
current background color to YELLOW. Remember that default drawing color is
WHITE and background color is BLACK.
setbkcolor function in c
![Page 25: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/25.jpg)
main() { int gd = DETECT, gm; initgraph(&gd, &gm, "C:\\TC\\BGI"); Setbkcolor(3); Outtextxy(250,350,“HELLO WORLD”); getch(); }
![Page 26: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/26.jpg)
output
![Page 27: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/27.jpg)
Declaration :- void setcolor(int color); In Turbo Graphics each color is assigned a
number. Total 16 colors are available. Strictly speaking number of available colors depends on current graphics mode and driver.For Example :- BLACK is assigned 0, RED is assigned 4 etc.
setcolor function is used to change the current drawing color.e.g. setcolor(RED) or setcolor(4) changes the current drawing color to RED. Remember that default drawing color is WHITE.
setcolor function in c
![Page 28: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/28.jpg)
main() { int gd = DETECT, gm;
initgraph(&gd,&gm,"C:\\TC\\BGI"); circle(100,100,50); /* drawn in white color */
setcolor(RED); circle(200,200,50); /* drawn in red color */ getch(); }
![Page 29: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/29.jpg)
output
![Page 30: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/30.jpg)
Declaration :- void setfillstyle( int pattern, int color); Different fill styles:
enum fill_styles { EMPTY_FILL, SOLID_FILL, LINE_FILL, LTSLASH_FILL, SLASH_FILL, BKSLASH_FILL, LTBKSLASH_FILL, HATCH_FILL, XHATCH_FILL, INTERLEAVE_FILL, WIDE_DOT_FILL, CLOSE_DOT_FILL, USER_FILL };
setfillstyle function in c
![Page 31: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/31.jpg)
main() { int gd = DETECT, gm; initgraph(&gd, &gm, "C:\\TC\\BGI"); setfillstyle(XHATCH_FILL, RED); circle(100, 100, 50); floodfill(100, 100, WHITE); getch(); }
Program
![Page 32: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/32.jpg)
output
![Page 33: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/33.jpg)
Settextstyle function is used to change the way in which text appears, using it we can modify the size of text, change direction of text and change the font of text.
Declaration :- void settextstyle( int font, int direction, int charsize);
font argument specifies the font of text, Direction can be HORIZ_DIR (Left to right) or VERT_DIR (Bottom to top).
settextstyle function in c
![Page 34: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/34.jpg)
enum font_names { DEFAULT_FONT, TRIPLEX_FONT, SMALL_FONT, SANS_SERIF_FONT, GOTHIC_FONT, SCRIPT_FONT, SIMPLEX_FONT, TRIPLEX_SCR_FONT, COMPLEX_FONT, EUROPEAN_FONT, BOLD_FONT };
Different fonts
![Page 35: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/35.jpg)
main() { int gd = DETECT, gm, x = 25, y = 25, font = 0; initgraph(&gd,&gm,"C:\\TC\\BGI"); for ( font = 0 ; font <= 10 ; font++) { settextstyle(font, HORIZ_DIR, 1); outtextxy(x, y, "Text with different fonts"); y = y + 25; } getch(); }
C programming source code for settextstyle
![Page 36: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/36.jpg)
output
![Page 37: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/37.jpg)
void main() { int gd=DETECT,gm; initgraph(&gd,&gm,"c:\\TurboC3\\bgi"); setbkcolor(3); setcolor(4); line(100,400,300,400); line(100,400,100,200); line(300,400,300,200); line(100,200,200,100); line(200,100,300,200); line(150,400,150,300); line(250,400,250,300); line(150,300,250,300); circle(200,200,40); getch(); }
C programming source code for home application
![Page 38: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/38.jpg)
output
![Page 39: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/39.jpg)
Sunrise using paint
![Page 40: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/40.jpg)
void main() { int gd=DETECT,gm; initgraph(&gd,&gm,"c:\\TurboC3\\bgi"); line(150,475,520,475); arc(330,475,0,180,50); line(330,428,330,320); line(370,445,440,390); getch(); }
Sunrise using paint
![Page 41: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/41.jpg)
![Page 42: putpixel function plots a pixel at location (x, y) of specified color. Declaration :- void putpixel(int x, int y, int color);](https://reader035.vdocuments.mx/reader035/viewer/2022062223/551a9ae955034643688b6176/html5/thumbnails/42.jpg)
THANK YOU