image thumbnail
from Geo Magic Squares by Krishna Lalith
Identify 20 Geo Magic Squares with 4-Hexaminos.

GMS(action)
function GMS(action)

global fig Counter Links x y hand CC Soln_Links summe compli slink Dbase;
clc
%--------------------------------------------------------------------------
if nargin < 1, 
    CC=[119 136 153]/256;
    Counter=0;
    Links=[];
    Dbase=0;
    
    scrsz = get(0,'ScreenSize');
    posit=[scrsz(3)/5 scrsz(3)/15 scrsz(3)/2.25 scrsz(4)/1.25];
    fig=figure('Name','Geo Magic Squares','NumberTitle','off', ...
               'Visible','off','BackingStore','off',...
               'position',posit);
     
    x=[2:2:12 12*ones(1,5) 10:-2:2 2*ones(1,4)];
    y=[14*ones(1,6) 12:-2:4 4*ones(1,5) 6:2:12];
    for ii=1:20,    
        cdata=imread([int2str(ii),'.tif']);    
        slink(ii)=uicontrol('style','pushbutton','units','centimeters',...
                            'position',[x(ii) y(ii) 2 2],'CData',cdata,...
                            'visible','off'); 
    end   
    
    %Hexaminos
%     x=[4:2:10 14*ones(1,4) 10:-2:4 0*ones(1,4)];
%     y=[16*ones(1,4) 12:-2:6 2*ones(1,4) 6:2:12];
    x=[4:2:10 4:2:10 4:2:10 4:2:10];
    y=[12*ones(1,4) 10*ones(1,4) 8*ones(1,4) 6*ones(1,4)];
    for ii=1:16,    
        cdata=imread([int2str(ii+10),'0.tif']);    
        hand(ii)=uicontrol('style','pushbutton','units','centimeters',...
                           'position',[x(ii) y(ii) 2 2],'CData',cdata,...
                           'callback',{@Draw_GMS,ii}); 
    end
    
    %creating 10 Soln Link Definitions
    for kk=1:4,
        if kk==1, Soln_Links(kk,:)=kk+(0:5:15); end
        if kk==4, Soln_Links(kk+2,:)=kk+(0:3:9); end
        Soln_Links(kk+1,:)=kk+(0:4:12);
        Soln_Links(kk+6,:)=(4*kk-3)+(0:3);
    end
    summe=[34 28 32 36 40 34 10 26 42 58];
    compli=[11 15 14 13 12 16 20 19 18 17];
    
    %creating default buttons
    uicontrol('units','centimeters',...
                'position',[4 3.3 1.2 0.6],'string','Link',...
                'callback','GMS(''Link'')',...
                'interruptible','on','BackgroundColor',CC);
            
    uicontrol('units','centimeters',...
                'position',[6 3.3 1.2 0.6],'string','About',...
                'callback','GMS(''About'')',...
                'interruptible','on','BackgroundColor',CC);
            
    uicontrol('units','centimeters',...
                'position',[8 3.3 1.2 0.6],'string','Ans.',...
                'callback','GMS(''Ans.'')',...
                'interruptible','on','BackgroundColor',CC);

    uicontrol('units','centimeters',...
                'position',[10 3.3 1.2 0.6],'string','Exit',...
                'callback','delete(gcf)',...
                'interruptible','on','BackgroundColor',CC);
         
    figure(fig);
    action='';
end
%--------------------------------------------------------------------------
if strcmp(action,'Link'),   
    Counter=0;
    for ii=1:length(Links),
        set(hand(Links(ii)),'enable','on');
    end
    Links=[];
end
%--------------------------------------------------------------------------
if strcmp(action,'Ans.'),
    scrsz = get(0,'ScreenSize');
    Helpfig=figure('Name','Answer','NumberTitle','off','Visible','off','BackingStore','off');
    figure(Helpfig);   
    image(imread('GMS4x6.jpg'));
    set(Helpfig,'Position',[scrsz(3)/8 scrsz(3)/8 scrsz(3)/2 scrsz(4)/1.25]);
    axis off
    if ~waitforbuttonpress,  close(Helpfig);  end
end
%--------------------------------------------------------------------------
if strcmp(action,'About'),
    msg={'How 2 Play:'...
         '                                                               ',... 
         'Objective: Identify 20 Geo Magic Squares with ONLY 4 Hexaminos.',... 
         '                                                               '...
         '     1) Select 4 Hexaminos by clicking on them.                ',...
         '     2) A correct Combination will be highlighted.             ',...
         '     3) Click on LINK button to START new SELECTION.           '};
     
    msgbox(msg,'Geo Magic Squares','help'); 
end
%--------------------------------------------------------------------------
if strcmp(action,'Exit') 
    closereq;
end
%--------------------------------------------------------------------------

Contact us