/* Fall 2022 Lab 8
gavin smyre
section 007
10/21/22
the progrma will build and create and accurate flag using functions
*/

#include <stdio.h>

struct header {
	char type[3];
	int width;
	int height;
	int maxColor;
}header_t;
struct pixel {
	unsigned int r;
	unsigned int g;
	unsigned int b;
}pixel_t;

int getWidth();
writeHeader(int header1);
fillFlagArray(unsigned int array, int width, int height);
writePixels(unsigned int array, int width, int height);

int main (){
struct header header1;
struct pixel pixel1;
	int i, j, k = 0;  // k is used for the array
//sets everything up
	fprintf(stderr, "\n\nFlag of Ireland");
	fprintf(stderr, "\n\tWhat width do you want the flag to be? ");
	scanf("%d", &header1.width);	
header1.height=header1.width/2;	

//ratio of flag

	fprintf(stderr, "\n\nMaking the flag with width %d & height %d ...",
		header1.width, header1.height);
	fprintf(stderr, "\n\n");

//setting up array
	unsigned int array[header1.width*header1.height];

//set up header

	fprintf(stdout, "P3\n");
	fprintf(stdout, "%d %d %d\n", header1.width, header1.height, 255);
	
//the values of color
	for (i=0; i<header1.height; i++ ) {
	int green=0;
	int white=(header1.width)/3;
	int orange=(2*header1.width)/3;
	
	   for ( j=green; j<white; j++) {
		   fprintf(stdout, "%i %i %i\n",0,128,0);  
			 
		}
		for ( j=white; j<orange; j++) {
			fprintf(stdout, "%i %i %i\n",255,255,255);
		}
		for ( j=orange; j<header1.width; j++) {
			fprintf(stdout, "%i %i %i\n",255,165,0);
		}
	}
	return 0;
}

