% modified from Professor Militzer's code for a Menger Sponge

function square(r,d1,d2,color)

p1(:,1) = r;
p1(:,2) = r+d1;
p2(:,1) = r+d2;
p2(:,2) = r+d1+d2;

h=surf([p1(1,:); p2(1,:)], [p1(2,:); p2(2,:)], [p1(3,:); p2(3,:)]);  
set(h,'edgecolor','none','facecolor',color,'facelighting','gouraud');    
end
