动图效果:
代码如下:
filename = '问题儿童.gif';
% 创建图形窗口并设置属性
hFigure=figure('menubar','none','NumberTitle','off','position',...
[100 100 350 400],'name','问题儿童');
movegui(hFigure,'center');%居中
%创建坐标轴,用于显示背景图片和文本
hAxes=axes('visible','off','units','normalized','position',[0 0 1 1]);
%% 方块
rectangle('Position',[-26,65,52,46],'Curvature',[0.2 0.2],'edgecolor','k','facecolor','y','linewidth',3);
hold on
rectangle('Position',[-23,104,3,3],'Curvature',[1 1],'edgecolor','k','facecolor','k');
rectangle('Position',[20,104,3,3],'Curvature',[1 1],'edgecolor','k','facecolor','k');
rectangle('Position',[-23,70,3,3],'Curvature',[1 1],'edgecolor','k','facecolor','k');
rectangle('Position',[20,70,3,3],'Curvature',[1 1],'edgecolor','k','facecolor','k');
%% 头
theta=0:0.01:2*pi;
x=50*cos(theta); y=48*sin(theta);
h=plot(x,y,'k','linewidth',6);
h1=fill(x,y,'w');
%% 眼睛
theta=0:0.01:pi;
xL1=-20+8*cos(theta); yL1=6+9*sin(theta);
hL1=plot(xL1,yL1,'k','linewidth',3,'EraseMode','xor');
theta=0:0.01:pi;
xR1=20+8*cos(theta); yR1=6+9*sin(theta);
hR1=plot(xR1,yR1,'k','linewidth',3,'EraseMode','xor');
%% 嘴
x2=[0 -7 7 0]; y2=[-10 1 1 -10];
h2=plot(x2,y2,'k','linewidth',3,'EraseMode','xor');
%% 身体
x3=[2