
/**********************************************************/
/**    This program makes a *.bil graphics format file   **/
/**  with a visual (color) res of 8x8 blocks going from  **/
/**      white at top left to black at bottom right.     **/
/**  The actual res can be up to 64x64, but only eight   **/
/**            colors can be along one side.             **/
/**   NOTE: It takes FOUR nested loops to do this! :-)   **/
/**********************************************************/

#include <stdio.h>

void main()
{
	FILE *textout;
	int level, i, j, k, m, ttm;
        char name[20];

	printf("\n\nEnter name of file to make: ");
	scanf(" %s", name);
	if((textout=fopen(name,"wt"))==NULL) 
		printf("\nCan't open file %s!\n",name);
	else {
		level=-1;
                while(!(level<=6 && level>=3)) {
			printf("What level do you want to make (3-6)? ");
			scanf(" %d",&level);
		}
		fprintf(textout,"%d\n",level);
		ttm=1;
                for(i=1;i<=level;i++) ttm*=2;

		for(i=15;i>=8;i--) 
			for(k=1;k<=(ttm/8);k++) {
				for(j=i;(i-j)<8;j--)
					for(m=1;m<=(ttm/8);m++)
						fprintf(textout,"%f ", ((float)j/15.0));
				fprintf(textout,"\n");
			}
	}
	fclose(textout);
}
                        	
