image thumbnail

Mathworks Rubik version 2

by

 

04 Apr 2013 (Updated )

Display, tester and solver of the Rubik's game, including "full cubes".

uicontrol(hFCongr,'Style','text',... 'Position',[10 10 Pos1(3:4)-20],... 'FontName','Comic Sans MS','FontSize',28,... 'ForegroundColor',[0 0 1],... 'String','Congratulations!'); else figure(hFCongr); set(hFCongr,'Position',Pos1); end
function Congr(hAxes,Cube)
%Congr -  Test completeness of cube, and, if appropriate, give a Congratulation-message
%    Congr(hAxes,Cube)

Color=Cube.Color;
NumColor=Cube.RotLayerCube;
for k1=1:6, % check any side
	onesq = Color(k1,NumColor(k1,1)); % one square of side
	if any(Color(k1,NumColor(k1,2:9))~=onesq)
		return
	end
end
if Cube.bFullCube
	for x=1:6
		for y=1:4
			z=Cube.iExtraFaces(x,y);
			if Cube.Color(z,Cube.iMid(x))~=Cube.Color(Cube.iMidInd(z))
				return
			end
		end
	end
end
hFig = get(hAxes,'Parent'); % main figure handle
Pos = get(hFig,'Position');
dPos = [20,200,-40,-380];
Pos1 = Pos+dPos; % new position
hFCongr=findobj('Tag','RubikCongr');
if isempty(hFCongr)
	hFCongr = figure('Position',Pos1,...
		'Color',get(0,'DefaultUicontrolBackgroundColor'),...
		'Resize','off','MenuBar','none',...
		'NumberTitle','off','Name','Rubik Cube Game Congratulations',	...
		'Tag','RubikCongr'	...
		);
	hTCongr = uicontrol(hFCongr,'Style','text',...
		'Position',[10 10 Pos1(3:4)-20],...
		'FontName','Comic Sans MS','FontSize',28,...
		'ForegroundColor',[0 0 1],...
		'String','Congratulations!');
else
	figure(hFCongr);
	set(hFCongr,'Position',Pos1);
end

Contact us