/*
 * Soubor:  20120105-Thu-matice-obrazek.c
 * Datum:   05.01.2012 08:27
 * Autor:   Marek Nožka, nozka <@t> spseol <d.t> cz
 * Licence: GNU/GPL 
 * Úloha:   
 * Popis:   
 ****************************************************/
#define _ISOC99_SOURCE
#define _GNU_SOURCE
#include <stdio.h>
#include <stdbool.h>

#define RADKU 128
#define SLOUPCU 128


/****************************************************
 *               Hlavní program.
 ****************************************************/
int main(void)
{
    int i, j;
    char barva;
    char matice[RADKU][SLOUPCU];

/* - je černá 
 * + je bílá */

    /* naplním matici daty */
    for (i = 0; i < RADKU; i++) {
        // barva =  i % 2 == 0 ? '+': '-';
        if (i % 2 == 0) {
            barva = '+';
        } else {
            barva = '-';
        }
        for (j = 0; j < SLOUPCU; j++) {
            matice[i][j] = barva;
        }
    }

    /* uložím matici do obrázku */
    FILE *soubor;
    soubor = fopen("matice.xpm", "w");
    fprintf(soubor, "! XPM2\n%d %d 2 1\n",RADKU,SLOUPCU);
    fprintf(soubor, "- c #000000\n");
    fprintf(soubor, "+ c #ffffff\n");
    for (i = 0; i < RADKU; i++) {
        for (j = 0; j < SLOUPCU; j++) {
            fputc(matice[i][j], soubor);
        }
        fputc('\n', soubor);
    }

    fclose(soubor);


    return 0;
}

