H=abs(X2-X1); V=abs(Y2-Y1);
sy=zeros(size(1));
sx=zeros(size(1));
reverse=zeros(size(1));
if X2<X1 
     sx=true; else sx=false; end
if Y2<Y1 
     sy=true; else sy=false; end
if H<V 
    reverse=true ;x=H ; H=V ; V=x;  else reverse=false; end;
if sym(H)==0 
     M(X1,Y1)=color4; end;

slope=V/H;
counter=zeros(size(1));
while counter<=H 
    x=counter;
    y=floor(slope*x+0.5);
    if reverse
        z=x;x=y;y=z; end;
    if sx 
         x=-x; end;
    if sy 
         y=-y; end;
 
if color4~=M(x+X1+1,y+Y1)           %1,0
      M(x+X1+1,y+Y1)=color2; end;
 
if color4~=M(x+X1,y+Y1+1)           %0,1
      M(x+X1,y+Y1+1)=color2; end;
 
if color4~=M(x+X1+1,y+Y1+1)           %1,1
      M(x+X1+1,y+Y1+1)=color2; end;
   
if color4~=M(x+X1-1,y+Y1)           %-1,0
      M(x+X1-1,y+Y1)=color2; end;
   
if color4~=M(x+X1,y+Y1-1)           %0,-1
      M(x+X1,y+Y1-1)=color2; end;
   
if color4~=M(x+X1-1,y+Y1-1)           %-1,-1
      M(x+X1-1,y+Y1-1)=color2; end;
 
if color4~=M(x+X1-1,y+Y1+1)           %-1,1
      M(x+X1-1,y+Y1+1)=color2; end;
   
if color4~=M(x+X1+1,y+Y1-1)           %1,-1
      M(x+X1+1,y+Y1-1)=color2; end;
   

  
  
  
  
 
     
     
   counter=counter+1;
end;