Tutorials Infos - Anleitungen - Hilfe - Dreamcodes
 

Polygone zeichnen (BGI)

//Grafikbasierend
//Zeichnet 4 Fenster mit einem Dreieck, Viereck, Quader, Pyramide

#include
#include
#include


void LadeBgi(void);
void ZeichneRahmen(void);
void ZeichneRechteck(int,int,int,int,int);
void ZeichneQuader(int,int,int,int,int,int);
void ZeichneDreieck(int,int,int,int,int,int);
void ZeichnePyramide(int,int,int,int,int,int,int);



void main (void)
{
LadeBgi();
ZeichneRahmen();
ZeichneRechteck(50,50,220,150,10);
ZeichneQuader(50,300,220,150,10,4);
ZeichneDreieck(370,200,220,80,150,14);
ZeichnePyramide(370,450,220,80,150,10,9);
getch();
}

void ZeichneRahmen()
{
int maxX = getmaxx();
int maxY = getmaxy();
rectangle(0,0,maxX,maxY);
line(maxX/2,0,maxX/2,maxY);
line(0,maxY/2,maxX,maxY/2);
}


void ZeichneRechteck(int xPos, int yPos, int breite, int hoehe, int farbe)
{
setcolor(farbe);
rectangle(xPos,yPos,xPos+breite,yPos+hoehe);
}


void ZeichneQuader(int xPos, int yPos, int breite, int hoehe, int tiefe, int farbe)
{
setcolor(farbe);
tiefe = breite/100*tiefe;
ZeichneRechteck(xPos,yPos,breite,hoehe,farbe);
line(xPos,yPos,xPos+tiefe,yPos-tiefe);
line(xPos+breite,yPos,xPos+breite+tiefe,yPos-tiefe);
line(xPos+breite,yPos+hoehe,xPos+breite+tiefe,yPos+hoehe-tiefe);
line(xPos+tiefe,yPos-tiefe,xPos+breite+tiefe,yPos-tiefe);
line(xPos+breite+tiefe,yPos-tiefe,xPos+breite+tiefe,yPos+hoehe-tiefe);
}

void ZeichneDreieck(int xPos, int yPos,int breite ,int pqPunkt , int hoehe, int farbe)
{
setcolor(farbe);
line(xPos,yPos,xPos+breite,yPos);
line(xPos,yPos,xPos+pqPunkt,yPos+hoehe*(-1));
line(xPos+breite,yPos,xPos+pqPunkt,yPos+hoehe*(-1));
}


void ZeichnePyramide (int xPos, int yPos,int breite ,int pqPunkt , int hoehe, int tiefe, int farbe)
{
tiefe=breite/100*tiefe;
ZeichneDreieck(xPos,yPos,breite,pqPunkt,hoehe,farbe);
line(xPos+breite,yPos,xPos+breite+tiefe,yPos-tiefe);
line(xPos+breite+tiefe,yPos-tiefe,xPos+pqPunkt,yPos+hoehe*(-1));
}





//BGI Treiber laden

void LadeBgi()
{
int grafikTreiber, grafikModus;
char Treiberpfad[]="BGI";
grafikTreiber = DETECT;
initgraph(&grafikTreiber,&grafikModus, Treiberpfad);

if(grafikTreiber <= 0)
{
cputs(grapherrormsg(grafikTreiber));
getch();
exit(1);
}
}

 
ID: 320
eingestellt am: 12.03.2004
Autor: Semokum
Status zum lesen: Gast
gelesen: 4738
Webseite: www.dreamcodes.com
[Drucken]