/*
Lauren Dukes
CPSC 1110 example

Demonstrates reading in values from a file to fill in a 2D array.
Makes an image using those values using ANSI escape codes.
Also, uses a constant declaration.
*/

#include <stdio.h>

//declares a constant for use in the program
//this value is written into the program before it is compiled, 
//kind of like find and replace
#define IMGSIZE 11

int main(void){
	//declare an array of the correct size based on the value of the constant
	int imagearray[IMGSIZE][IMGSIZE];
	
	//declare counters for rows and columns
	int row = 0;
	int column = 0;

	//for each row
	for (row = 0; row < IMGSIZE; row++){
		//for each column
		for (column = 0; column < IMGSIZE; column++){
			//get the number from the file (or user input)
			int num;
			scanf("%d",&num);
			//assign that value to the 2D array at the current row and column
			imagearray[row][column] = num;
		}
	}	


	//for each row
	for (row = 0; row < IMGSIZE; row++){
		//for each column
		for (column = 0; column < IMGSIZE; column++){
			//use printf to write the correct ANSI escape code for the color, and print out a couple spaces in that color
			printf("\x1b[4%dm  ",imagearray[row][column]);
		}
		//at the end of each line, change the color to black and go to the next line using a newline
		printf("\x1b[40m\n");
	}

	return 0;
}
