lec 7 graphics in troduction to computing

FatimaAijaz6 7 views 12 slides Mar 03, 2025
Slide 1
Slide 1 of 12
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12

About This Presentation

Lecture 7


Slide Content

Graphics Made by Engr. Hira zahid

Settextstyle 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).

Different fonts enum font_names { DEFAULT_FONT, TRIPLEX_FONT, SMALL_FONT, S ANS_SERIF_FONT, GOTHIC_FONT, SCRIPT_FONT, SIMPLEX_FONT, TRIPLEX_SCR_FONT, COMPLEX_FONT, EUROPEAN_FONT, BOLD_FONT };

outtextxy 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.

getmaxx getmaxx function returns the maximum X coordinate for current graphics mode and driver. Declaration :- int getmaxx (); #include< graphics.h > #include< conio.h >   main() { int gd = DETECT, gm, max_x ; char array[100];   initgraph (& gd,&gm,“D : \\ TC \\ BGI");   max_x = getmaxx ();   sprintf (array, "Maximum X coordinate for current graphics mode and driver is = % d.",max_x ); outtext (array);   getch (); closegraph (); return 0; }

getmaxy getmaxy function returns the maximum Y coordinate for current graphics mode and driver. Declaration :- int getmaxy ()

cleardevice Declaration :- void cleardevice (); cleardevice function clears the screen in graphics mode and sets the current position to (0,0). Clearing the screen consists of filling the screen with current background color. #include < graphics.h > #include < conio.h >   main() { int gd = DETECT, gm; initgraph (& gd , &gm, "C: \\ TC \\ BGI"); outtext ("Press any key to clear the screen."); getch (); cleardevice (); outtext ("Press any key to exit..."); getch (); closegraph (); return 0; }

close graph close graph function closes the graphics mode, deallocates all memory allocated by graphics system and restores the screen to the mode it was in before you called initgraph . Declaration :- void closegraph ();

Countdown code #include < graphics.h > #include < dos.h > #include < conio.h >  #include< stdio.h > int main() { int gd = DETECT, gm, i ; char a[5];  initgraph ( & gd , &gm, “D: \\ TC \\ BGI");  settextjustify ( CENTER_TEXT, CENTER_TEXT ); settextstyle (DEFAULT_FONT,HORIZ_DIR,3); setcolor (RED);  for ( i = 30; i >=0; i --) { sprintf (a,"% d",i ); outtextxy ( getmaxx ()/2, getmaxy ()/2, a); delay(1000);  if ( i == 0 ) break ; cleardevice (); }  getch (); closegraph (); return 0; }

Conio.h functions clrscr delline getch getche gotoxy kbhit wherex wherey textcolor textbackground

Math.h functions abs ceil cos floor log log10 pow pow10 sin sqrt

dos.h dos.h in c: dos.h header file of c language contains functions for handling interrupts, producing sound, date and time functions etc. It is borland specific and works in turbo c compiler. dos.h functions delay getdate gettime nosound setdate sleep sound
Tags