#include<stdlib.h>
#include <stdio.h>

#define BLANC 'o'
#define NOIR '#'
#define GRIS '.'
#define H 30
#define L 30

/* declaration des fonctions utilisateurs */

/* dessine un point de couleur p et de coordonnees (x,y) */
void Point(int x, int y, char p, char Image[H][L]);

/* dessine un segment horizontal de couleur p entre les points (x1,y) et (x2,y) */
void Trait(int x1, int x2, int y, char p, char Image[H][L]);

/* dessine un rectangle de couleur p dont les angles sont (x1,y1) et (x2,y2) */
void Rectangle(int x1, int x2, int y1, int y2, char p, char Image[H][L]);

/* affiche un pixel */
void AffichePixel(int x, int y, char Image[H][L]);

/* affiche une image */
void AfficheImage(char Image[H][L]);

/* programme principal */
int main()
{
	int i,j;
	char Image[H][L];

	for(i=0;i<H;i++)
		for(j=0;j<L;j++)
			Point(i,j,BLANC,Image);
	Rectangle(1,5,20,30,NOIR,Image);
	Rectangle(10,15,15,20,GRIS,Image);
	AfficheImage(Image);

	return EXIT_SUCCESS;
}

/* definition des fonctions utilisateurs */

/* dessine un point de couleur p et de coordonnees (x,y) */
void Point(int x, int y, char p, char Image[H][L])
{
	Image[y][x]=p;
}

/* dessine un segment horizontal de couleur p entre les points (x1,y) et (x2,y) */
void Trait(int x1, int x2, int y, char p, char Image[H][L])
{
	int i;

	for(i=x1-1;i<x2;i++)
		Point(i,y,p,Image);
}

/* dessine un rectangle de couleur p dont les angles sont (x1,y1) et (x2,y2) */
void Rectangle(int x1, int x2, int y1, int y2, char p, char Image[H][L])
{
	int i;
	
	for(i=y1-1;i<y2;i++)
		Trait(x1,x2,i,p,Image);
}

/* affiche un pixel */
void AffichePixel(int x, int y, char Image[H][L])
{
	printf("%c",Image[x][y]);
}

/* affiche une image */
void AfficheImage(char Image[H][L])
{
	int i,j;

	for(i=0;i<H;i++)
	{
		for(j=0;j<L;j++)
			AffichePixel(i,j,Image);
		printf("\n");
	}
	printf("\n");
}


