#include <stdio.h>
#include "functions.h"
#include <math.h>

void make_ppm_header(header_t hdr)
{
	fprintf(stdout, "P6\n");
	fprintf(stdout, "%d %d %d\n", hdr.width, hdr.height, 255);
}

void make_pixel(pixel_t pix)
{
	fprintf(stdout, "%c%c%c", pix.r, pix.g, pix.b);
}

void circles(header_t hdr)
{

	//header_t hdr = {600, 400};
	make_ppm_header(hdr);
	int radius = 75;
	int radius2 = 100;
	int radius3 = 50;
	int cx = 350;
	int cy = 200;
	int cx2 = 150;
	int cx3 = 500;
	

	/*row is y and col is x*/
	for(int row = 0; row < hdr.height ; row++)
	{
		for(int col = 0; col < hdr.width; col++)
		{
			if(sqrt(((col - cx) * (col - cx)) + ((row - cy)*(row - cy)))< radius)
			{
				printf("%c%c%c",255,0,0);
			}
			else if(sqrt(((col - cx2) * (col - cx2)) + ((row - cy)*(row - cy)))< radius2)
			{
				printf("%c%c%c",255,0,0);
			}
			else if(sqrt(((col - cx3) * (col - cx3)) + ((row - cy)*(row - cy)))< radius3)
			{
				printf("%c%c%c",255,0,0);
			}
			else
			{
				printf("%c%c%c",0,0,255);
			}
				
		}	
	}
}