3 de março de 2009

Projeto I

Bandeira do Leandro Hossaki
(Com a super estrela! xD)


#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int left, top, right, bottom;
int x, y, i;
int poly[12];

/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");

/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}

/* draw a rectangle */
left = 30;
top = 10;
right = 610;
bottom = 470;

setfillstyle(SOLID_FILL, 2);
setcolor(2);
rectangle(left,top,right,bottom);
floodfill(50,20,2);

setfillstyle(SOLID_FILL, 15);
setcolor(15);
rectangle(30,100,610,370);
floodfill(50,120,15);

setfillstyle(SOLID_FILL, 4);
setcolor(4);
rectangle(30,150,610,320);
floodfill(50,170,4);

poly[0] = 6;
poly[1] = 11;

poly[2] = 36;
poly[3] = 11;

poly[4] = 12;
poly[5] = 28;

poly[6] = 21;
poly[7] = 0;

poly[8] = 30;
poly[9] = 28;

for(i=1;i<=9;i+=2){
poly[i-1] = poly[i-1] * 5 + 210;
poly[i] = poly[i] * 5 + 165;
}

poly[10] = poly[0];
poly[11] = poly[1];

setfillstyle(SOLID_FILL,14);
setcolor(14);
fillpoly(6,poly);
x = poly[0] + (poly[2] - poly[0])/2;
y = poly[1] + 20;
floodfill(x,y,14);

/* clean up */
getch();
closegraph();
return 0;
}

0 comentários: