res=0.01;
x=[-1:res:1];
y=[-1:res:1];
x=ones(length(x),1)*x;
y=y'*ones(1,length(y));
c1=(floor(log(x.*x+y.*y)/log(2)))==(ceil(log(max(abs(x),abs(y)))/(log(2)/2))-1);% for i=0:n

n=length(c1)-1;
c2=~c1;
c3=zeros(n);
i=floor(n*(1-sqrt(2)/2)/2);
inds=(1+i):(n+1-i);
c3=zeros(size(c2));
c3(inds,inds)=c2(inds,inds);

sq1=zeros(n+1);
%figure
plot(1)
imtool(sq1);

sq2=zeros(n+1,n+1,3);
sq2(:,:,1)=c1;
sq2(:,:,2)=c2;
imtool(sq2);

h1=ones(n+1,n+1,3);
h1(:,:,2)=h1(:,:,2)-c1;
h1(:,:,3)=h1(:,:,3)-c1;
imview(h1);

h2=ones(n+1,n+1,3);
h2(:,:,1)=h2(:,:,1)-c3;
h2(:,:,3)=h2(:,:,3)-c3;
imtool(h2);

cir1=ones(n+1,n+1,3);
cir1(:,:,2)=cir1(:,:,2)-c1;
cir1(:,:,3)=cir1(:,:,3)-c1;
cir1(:,:,1)=cir1(:,:,1)-c3;
cir1(:,:,3)=cir1(:,:,3)-c3;
imtool(cir1);

cir2=ones(n+1)-c1-c3
imtool(cir2);
