clear all

MaxX=100;MaxY=100;
global M
M=zeros(MaxX,MaxY);

nv=10000;
set(0,'recursionlimit',nv);
global color2
color=23;
color2=56;
lineColor=23;
global Ax
Ax=axes;
image(M');set(Ax,'YDir','normal');

[X,Y]=ginput(4);

X=floor(X);
Y=floor(Y);

A1=(X(1));A2=(Y(1));
B1=(X(2));B2=(Y(2));
C1=(X(3));C2=(Y(3));
D1=(X(4));D2=(Y(4));

M(A1,A2)=color;
M(B1,B2)=color;
M(C1,C2)=color;
M(D1,D2)=color;

DrawLine(A1,A2,B1,B2,lineColor);  
DrawLine(B1,B2,C1,C2,lineColor);   
DrawLine(C1,C2,D1,D2,lineColor);   
DrawLine(D1,D2,A1,A2,lineColor);   

image(M');
set(Ax,'YDir','normal');
counter=0;
while 2>counter
    [CenterX,CenterY]=ginput(1);

    CenterX=floor(CenterX);
    CenterY=floor(CenterY);

    XX=CenterX;
    YY=CenterY;
    %%SimpleFloodFill(XX,YY);
    FillMe;
    image(M');set(Ax,'YDir','normal');
    counter=counter+1;
end

