- 5.11 Figure 5.22 Program to draw a quilt
#include <iostream>
using namespace std;
int main(void)
{
int x1,y1,x2,y2,stepX,stepY,foreColor,numBars,width, height;
cout<<"Enter number of bars> ";
cin>>numBars;
width = getmaxwidth();
height = getmaxheight();
initwindow(width, height, "Quilt");
x1=0;
x2=width;
y1=0;
y2=height;
stepX = width/(2 * numBars);
stepX = height/(2 * numBars);
for (int i= 1; i<= numBars; ++i){
foreColor= i%16;
setcolor(foreColor);
setfillstyle(i%12, foreColor);
bar(x1, y1, x2, y2);
x1 = x1 + stepX;
y1 = y1 + stepY;
x2 = x2 - stepX;
y2 = y2 - stepY;
}
closegraph();
system("PAUSE");
return EXIT_SUCCESS;
0 komentar:
Posting Komentar