www.gusucode.com > 九宫图游戏源码程序 > 九宫图游戏源码程序/九宫图游戏/plotboard.m

    function [] = plotboard(handles,board,result,points)
colors=[[1 1 1];[1 0.8 0.4];[1 0.4 0.4];[1 0.2 0.2];[0.8 0 0];[1 1 0];[0.8 0.8 0];[0.4 0.6 0];[0 0.6 0.6];[0 1 1]];
global tilesize
for i=1:(size(board,1)*size(board,2))
    set(eval(['handles.p' num2str(i)]),'Visible','on');
    if board(i)~=0
        set(eval(['handles.p' num2str(i)]),'String',num2str(board(i)));
        if log2(board(i))>length(colors(:,1))
            color=colors(end,:);
        else
            color=colors(log2(board(i)),:);
        end
        set(eval(['handles.p' num2str(i)]),'BackgroundColor',color)
    else
        color=[0 0 0];
        set(eval(['handles.p' num2str(i)]),'BackgroundColor',color)   
        set(eval(['handles.p' num2str(i)]),'String','');
    end
    set(eval(['handles.p' num2str(i)]),'FontWeight','bold');
    set(eval(['handles.p' num2str(i)]),'FontUnits','pixels');
    set(eval(['handles.p' num2str(i)]),'FontSize',round(tilesize/4));
end
switch result
    case 0
        set(handles.result,'String','');
    case 1
        set(handles.result,'String','WIN');
    case -1
        set(handles.result,'String','LOSS');
end

set(handles.points,'String',num2str(points));

end