标签:style blog http io color os ar on 2014
clc;
clear all;
close all;
%% 台灯的设置
figure(‘color‘,‘k‘)
% 底座
fill3([0 1 1 0],[0 0 1 1],[0 0 0 0],‘b‘,...
[1 1 1 1],[0 0 1 1],[0 0.5 0.5 0],‘b‘,...
[1 1 0 0],[0 1 1 0],[0.5 0.5 0.5 0.5],‘g‘,...
[0 1 1 0],[1 1 1 1],[0 0 0.5 0.5],‘b‘);
grid on
hold on
% x = ‘.1*cos(t) + 0.2‘;
% y = ‘.1*sin(t) + 0.5‘;
% z = ‘s‘;
% ezmesh(x ,y,z,[0,2*pi,0.5,1]);
%后侧面
fill3([0 0.1 0.1 0],[0.2 0.2 0.8 0.8],[0.5 0.5 0.5 0.5],‘m‘,...
[0.1 0.1 0.1 0.1],[0.2 0.2 0.8 0.8],[0.5 4.1 4.1 0.5],‘m‘,...
[0.1 0.1 0 0],[0.2 0.8 0.8 0.2],[4.1 4.1 4.1 4.1],‘m‘,...
[0 0.1 0.1 0],[0.8 0.8 0.8 0.8],[0.5 0.5 4.1 4.1],‘m‘);
%顶面
fill3([0 0.7 0.7 0],[0 0 1 1],[4.1 4.1 4.1 4.1],‘b‘,...
[0.7 0.7 0 0],[0 0 1 1],[4.1 4.2 4.2 4.1],‘b‘,...
[0.7 0.7 0 0],[0 1 1 0],[4.2 4.2 4.2 4.2],‘b‘,...
[0 0.7 0.7 0],[1 1 1 1],[4.1 4.1 4.2 4.2],‘b‘);
view([135 38])
axis([-1,2,-1,2,0,5])
% 绘制球体
x=‘.2*sin(s)*sin(t) + 0.4‘;
y=‘.2*sin(s)*cos(t) + 0.4‘;
z=‘.2*cos(s) + 3.3‘;
ezmesh(x,y,z,[0 pi*2 0 pi*2])
axis off
%% light
plotbutton=uicontrol(‘style‘,‘pushbutton‘,...
‘string‘,‘On‘, ...
‘fontsize‘,12, ...
‘position‘,[100,400,50,20], ...
‘callback‘, ‘On=1;‘); %define the stop button
erasebutton=uicontrol(‘style‘,‘pushbutton‘,...
‘string‘,‘Of‘, ...
‘fontsize‘,12, ...
‘position‘,[200,400,50,20], ...
‘callback‘,‘Of=1;‘);
quitbutton=uicontrol(‘style‘,‘pushbutton‘,...
‘string‘,‘Color‘, ...
‘fontsize‘,12, ...
‘position‘,[300,400,50,20], ...
‘callback‘,‘Color=1;‘);
On = 0;
Of = 0;
Color = 0;
% cc = [1,0,0];
while (On == 1)
if Color == 1
cc = round(rand(1,3));
else
cc = [1,0,0];
end
light(‘color‘,cc,‘style‘,‘local‘,‘position‘,[3.1,3.1,3.1])
% light phong
% set(gca,‘CameraViewAngle‘,12)
if Of ==1
On = 0;
end
r = rand
drawnow
end
标签:style blog http io color os ar on 2014
原文地址:http://www.cnblogs.com/Kermit-Li/p/4055416.html