// Librairie a utiliser:
//
// D:\Michel\MesAppl\Spider_DLL\Spider\Debug\Spider.lib

#include <windows.h>
#include <iostream.h>
#include "Spider.h"
#include "SpiderDraw.h"
#include "SpiderUser.h"


int main(int argc,char *argv[],char *envp[])
    {
    cout << "Hello" << endl << endl;


    cout << "Ouverture fenetre..." << endl;

    Spider::initWindow("Programme de test");

    Spider::moveTo(700,700);
    Spider::Draw::Color color = Spider::Draw::getPixel();
    Spider::moveTo( 50, 50); Spider::Draw::displayText("0");
    Spider::moveTo(100,100); Spider::Draw::displayText("1");
    Spider::moveTo(150, 50); Spider::Draw::displayText("2");
    Spider::moveTo(200,100); Spider::Draw::displayText("3");
    Spider::moveTo(250, 50); Spider::Draw::displayText("4");
    Spider::moveTo(300,100); Spider::Draw::displayText("5");
    Spider::moveTo(350, 50); Spider::Draw::displayText("6");
    Spider::moveTo(400,100); Spider::Draw::displayText("7");
    Spider::moveTo(450, 50); Spider::Draw::displayText("8");
    Spider::moveTo(500,100); Spider::Draw::displayText("9");


  //  Spider::Draw::Color color;

    color.r = 0;
    color.g = 0;
    color.b = 0;
    for(color.r=0;(color.r<256);(color.r)++)
        {
        Spider::Draw::setColorPen(color);
        Spider::lineTo(50+color.r,250,
                       50+color.r,300);
        }

    color.r = 0;
    color.g = 0;
    color.b = 0;
    for(color.g=0;(color.g<256);(color.g)++)
        {
        Spider::Draw::setColorPen(color);
        Spider::lineTo(50+color.g,300,
                       50+color.g,350);
        }

    color.r = 0;
    color.g = 0;
    color.b = 0;
    for(color.b=0;(color.b)<256;(color.b)++)
        {
        Spider::Draw::setColorPen(color);
        Spider::lineTo(50+color.b,350,
                       50+color.b,400);
        }


    color.r = 255; color.g = 255; color.b =   0; Spider::Draw::setColorPen(color);
    Spider::moveTo(260,300); Spider::Draw::circle(10,Spider::Draw::noFill);
    Spider::moveTo(260,350); Spider::Draw::circle(10,Spider::Draw::fill);

    color.r =   0; color.g = 255; color.b = 255; Spider::Draw::setColorPen(color);


    int  x=0, y=0;
    int ax=0,ay=0;
    char car_temp;
    char car[2]; car[1] = 0x00;
    while(1)
        {
        if(Spider::User::keyPressed(&car_temp))
            car[0] = car_temp;

        if(Spider::User::leftClic(x,y))
            {
            Spider::lineTo(ax,ay,x,y);
            cout << "Ajout du point (" << x << "," << y << ")." << endl;

            Spider::Draw::displayText(car);
            
            ax = x;
            ay = y;
            }
        else
            {
            Spider::User::delay(50);
            }
        }

    Spider::User::delay(50000);

    Spider::closeWindow();


    while(1)
        ;

    return 0;
    }