Trecerea in modul grafic:
void far initgraph ( int far graphdriver int far graphmode char far path
Iesirea din modul grafic:
void closegraph (void) ;
Setarea Citirea culorii de fond:
void far setbkcolor (int culf ) ; int far getbkcolor (void ) ;
Setarea Citirea culorii de scriere:
void far setcolor (int culs ) ; int far getcolor (void ) ;
Alte functii:
Semnificatie |
Functii |
Numar de pixeli ( Oriz./Vert.) |
getmaxx getmaxy (); |
Coordonatele LPR (Ultimul Punct Referit |
getx gety (); |
Muta LPR (Abs./Rel.) |
moveto (x,y); moverel (dx,dy); |
Traseaza segment din LPR |
lineto (x,y); linerel (dx,dy); |
Traseaza segment |
line (x1,y1, x2,y2); |
Deseneaza dreptunghi |
rectangle (x1,y1, x2,y2); |
Deseneaza cerc |
circle (x,y,r); |
Scrie mesaj din LPR |
outtext xy x,y, mesaj); |
Pagina activa / Pagina vizuala |
setactivepage (pag); setvisualpage pag |
Exemple:
#include <graphics.h> // Graficul unei suprafete
#include 'graf.h'
#include <stdlib.h> #include <stdio.h> #include <conio.h> #include <math.h>
float Sqr (float x)
float z (float x, float y) // z=f(x,y)
void main(void)
Window(a,d,b,c); setbkcolor(BLUE);
for (i=0; i<=m; i++) } setcolor(YELLOW);
for (j=0; j<=n; j++) }
getch(); closegraph();
#include <graphics.h> // Graficul unei curbe
#include <conio.h>
#include <math.h>
#include 'graf.h'
float x (float t)
float y (float t)
float z (float t)
void main(void)
Window(a,d,b,c); int Pag=0; setbkcolor(BLUE);
enum Sem = Verde;
do
setvisualpage(Pag); Pag=1-Pag; setactivepage(Pag);
char Rasp=getch();
switch (Rasp&0x5F)
DefPr(Raza,Alfa);
} while (Sem==Verde);
// Graf.h
#include <graphics.h>
#include <math.h>
int u1,v1, u2,v2; // ViewPort
float a, b, c, d ; // Window
float Raza, Alfa; // Pr (r,a
int u (float x)
int v (float y)
void InitGraf(void)
void ViewPort(int x1,int y1,int x2,int y2)
void Window(float x1,float y1,float x2,float y2)
void Muta(float x,float y)
void Trag(float x,float y)
void DefPr(float r, float a)
float PrX (float x, float z)
float PrY (float y, float z)
|