function error_rectangle()

global eje pz cx cy sumejex sumejey ann prg

ancholin = .1;
fondo = [0 .2 1; .2 0 1; .2 1 0; 1 0 .2; 1 .8 0];

cuadrox = [0 10 10 0 0]; cuadroy = [0 0 10 10 0];
figure(1), clf, hold on

for k = 1:2
    subplot(1,2,k); hold on
    eje(k) = gca;
    for col = 1:13
        for fil = 1:8
            p(fil,col) = patch((fil-1)*10+cuadrox,(col-1)*10+cuadroy,[.8 .8 .8]);
            set(p(fil,col),'edgecolor',fondo(1,:)/16,'linewidth',ancholin);
        end
    end
    plot([20 70],[0 130],'-','color',fondo(1,:)/16,'linewidth',8);
    rr = rectangle('position',[0 0 80 130]);
    set(rr,'edgecolor',fondo(1,:)/16,'linewidth',6)
    axis equal
    axis([-1.5 81.5 -1.5 131.5])
    axis off
end

cx{1} = [0 0 70 20 0]; cx{2} = [80 80 60 60 70 70 80]; cx{3} = [70 70 60 60 50 50 70]; cx{4} = [50 50 (2+25/13)*10 20 50]; cx{5} = [80 80 70 (2+25/13)*10 80];
cy{1} = [0 130 130 0 0]; cy{2} = [0 50 50 30 30 0 0]; cy{3} = [0 30 30 50 50 0 0]; cy{4} = [0 50 50 0 0]; cy{5} = [50 130 130 50 50];

sumejex = zeros(2,5); sumejey = sumejex;
sumejex(2,:) = [0 0 10 30 -20];
sumejey(2,:) = [0 30 0 80 -50];

vis{1} = 'on'; vis{2} = 'off';
for k = 1:2
    subplot(1,2,k)
    for j = 1:5
        pz(k,j) = patch(sumejex(k,j)+cx{j},sumejey(k,j)+cy{j},fondo(j,:));
        set(pz(k,j),'edgecolor',fondo(1,:)/16,'linewidth',2,'facealpha',.5,'visible',vis{k});
    end
end

prg = ['global eje pz cx cy sumejex sumejey;',...
    'p = get(eje(1),''currentpoint''); p = p(1,1:2);',...
    'ejele = 1;',...
    'if abs(p(1)-40)>40 | abs(p(2)-65)>65, ',...
    'p = get(eje(2),''currentpoint''); p = p(1,1:2); ejele = 2;',...
    'if abs(p(1)-40)>40 | abs(p(2)-65)>65; return; end,',...
    'end,',...
    'zp = p(1)+i*p(2);',...
    'for k = 1:5, ',...
    'z = cx{k}+sumejex(ejele,k)+i*(cy{k}+sumejey(ejele,k));',...
    'tst = abs(sum(log(1+(z(2:end)-z(1:end-1))./(z(1:end-1)-zp))))>1;',...
    'if tst, pieza = k; continue; end,',...
    'end,',...
    'set(pz(ejele,pieza),''visible'',''off''),',...
    'set(pz(3-ejele,pieza),''visible'',''on'');'];


ann = annotation(1,'textbox','VerticalAlignment','middle',...
'String',{'Mouse clicking in any area will reallocate it in the opposite table.','','The question is: why is there a missing square?','','(click in any place to start playing)'},...
'HorizontalAlignment','center',...
'FontUnits','normalized',...
'FontSize',0.03,...
'FontAngle','italic',...
'FitHeightToText','on',...
'LineWidth',4,...
'BackgroundColor',[0.9412 0.9412 0.9412],...
'buttondownfcn','global eje pz cx cy sumejex sumejey ann prg, delete(ann), set(1,''buttondownfcn'',sprintf(''%s'',prg)); for k = 1:2, for j = 1:5, set(pz(k,j),''buttondownfcn'',sprintf(''%s'',prg)); end; end',...
'Position',[0.01 0.3959 0.98 0.4]);

set(1,'buttondownfcn','global eje pz cx cy sumejex sumejey ann prg, delete(ann), set(1,''buttondownfcn'',sprintf(''%s'',prg)); for k = 1:2, for j = 1:5, set(pz(k,j),''buttondownfcn'',sprintf(''%s'',prg)); end; end');
end