MATLAB draw little yellow people

Recently because of the epidemic, more boring at home, the way to learn matlab painting.
First of all, the Internet to find a small yellow stick figure people.
Internet to find small yellow stick figure people
Then, choose the origin of coordinates, the position coordinates to calculate the graphics to be drawn.
Finally, the code draw graphics, and fill color.
Here is a small yellow people for my own use matlab draw, as a rookie _ (|3 "∠) _, painted a little change.
Here Insert Picture Description
Attach small yellow people Code:

%===========================================%
%--------------MATLAB绘制小黄人--------------%
%===========================================%

clear all; %清除所有变量
close all; %清图
clc ;      %清屏

y0=[1,0.91314,0];%设置黄颜色
d=[0.11765,0.56471,1];%设置蓝颜色

%% 胳膊
%左边(圆心坐标为(125,252.5))
hg = hgtransform;
rectangle('Position',[-30,-125,40,40],'Curvature',[0.6 0.6],'edgecolor','k','facecolor',y0,'parent',hg,'linewidth',2)
hg.Matrix = makehgtform('zrotate',-pi/6);	% 绕原点(z轴)逆时针旋转60°
hold on
rectangle('Position',[-72.5,-90,6,5],'Curvature',[1 1],'edgecolor','k','facecolor','w','linewidth',2);

%右边(圆心坐标为(175,252.5))
hg = hgtransform;
rectangle('Position',[-10,-125,40,40],'Curvature',[0.6 0.6],'edgecolor','k','facecolor',y0,'parent',hg,'linewidth',2)
hg.Matrix = makehgtform('zrotate',pi/6);	% 绕原点(z轴)逆时针旋转60°
rectangle('Position',[66.5,-90,6,5],'Curvature',[1 1],'edgecolor','k','facecolor','w','linewidth',2);
axis equal

%% 头发
%第一根
theta=2*pi/6:0.1:4*pi/6;
x=-17+50*cos(theta);
y=8+50*sin(theta);
plot(x,y,'k','linewidth',2);
%第二根
theta=2*pi/6:0.1:3.9*pi/6;
x=-22+50*cos(theta);
y=10+50*sin(theta);
plot(x,y,'k','linewidth',2);
%第三根
theta=2.1*pi/6:0.1:4.1*pi/6;
x=21+50*cos(theta);
y=10+50*sin(theta);
plot(x,y,'k','linewidth',2);
%第四根
theta=2*pi/6:0.1:4*pi/6;
x=17+50*cos(theta);
y=8+50*sin(theta);
plot(x,y,'k','linewidth',2);

%% 身体
rectangle('Position',[-71,-55,142,110],'Curvature',[0.95 0.95],'edgecolor','k','facecolor',y0,'linewidth',2);
rectangle('Position',[-71,-164,142,110],'Curvature',[0.8 0.8],'edgecolor','k','facecolor',d,'linewidth',2);
rectangle('Position',[-71,-109,142,113],'Curvature',[0 0],'edgecolor','k','facecolor',y0,'linewidth',2);

%% 眼部
rectangle('Position',[-71,-4,142,8],'Curvature',[0 0],'edgecolor','k','facecolor','k');

%% 眼睛
%左边(圆心(-25,0),半径25)
rectangle('Position',[-50,-25,50,50],'Curvature',[1 1],'edgecolor','k','facecolor','w','linewidth',2);
%右边(圆心(25,0),半径25)
rectangle('Position',[0,-25,50,50],'Curvature',[1 1],'edgecolor','k','facecolor','w','linewidth',2);

%% 眼珠子
%左边(圆心(-25,0),半径11)
rectangle('Position',[-36,-11,22,22],'Curvature',[1 1],'edgecolor','k','facecolor','k');
%右边(圆心(25,0),半径11)
rectangle('Position',[14,-11,22,22],'Curvature',[1 1],'edgecolor','k','facecolor','k');

%% 眼白
%左边(圆心(-22,3),半径5)
rectangle('Position',[-27,-2,10,10],'Curvature',[1 1],'edgecolor','w','facecolor','w');
%右边(圆心(28,3),半径5)
rectangle('Position',[23,-2,10,10],'Curvature',[1 1],'edgecolor','w','facecolor','w');

%% 嘴巴(圆弧)(圆心(0,0),半径50)
theta=4*pi/3:0.1:5*pi/3;
x=50*cos(theta);
y=50*sin(theta);
plot(x,y,'k','linewidth',2);

%% 衣服
%先画矩形
rectangle('Position',[-52,-109,104,39],'Curvature',[0 0],'edgecolor','k','facecolor',d,'linewidth',2);
%再画蓝色的直线遮盖
plot([-52 52],[-109 -109],'color',d,'linewidth',2);%与x轴平行的直线
%裤缝(黑色直线)
plot([0 0],[-140 -164],'k','linewidth',2);%与y轴平行的直线

%% 肩带(多边形)
%左边
xL=[-71 -34 -45 -71];
yL=[-46 -77 -88 -65];
plot(xL,yL,'k','linewidth',2);
fill(xL,yL,d);
%右边
xR=[71 34 45 71];
yR=[-46 -77 -88 -65];
plot(xR,yR,'k','linewidth',2);
fill(xR,yR,d);
%左边纽扣(直径为6,圆心坐标为(-50,-79))
rectangle('Position',[-48,-81,6,6],'Curvature',[1 1],'edgecolor','k','facecolor','k');
%右边纽扣(直径为6,圆心坐标为(50,-79))
rectangle('Position',[42,-81,6,6],'Curvature',[1 1],'edgecolor','k','facecolor','k');

%% 裤兜(圆弧)
%左边(圆心(-71,-109),半径18)
theta=1.52*pi:0.01:1.85*pi;
x2=-71+18*cos(theta);
y2=-109+18*sin(theta);
plot(x2,y2,'k','linewidth',2);
%右边(圆心(71,-109),半径18)
theta=1.15*pi:0.01:1.48*pi;
x2=71+18*cos(theta);
y2=-109+18*sin(theta);
plot(x2,y2,'k','linewidth',2);

%% 口袋
%先画直线
plot([-18 18],[-93 -93],'k','linewidth',2);%与x轴平行的直线
plot([-18 -18],[-93 -103],'k','linewidth',2);%与y轴平行的直线
plot([18 18],[-93 -103],'k','linewidth',2);%与y轴平行的直线
%再画圆弧(圆心(0,-103),半径18)
theta=pi:0.01:2*pi;
x2=0+18*cos(theta);
y2=-103+18*sin(theta);
plot(x2,y2,'k','linewidth',2);

%% 小脚丫(多边形)
%左边
xL1=[-22 -22];
yL1=[-164 -172];
theta=4*pi/9:0.1:4*pi/3;%圆弧
xL2=-37+8*cos(theta);
yL2=-179.07+8*sin(theta);
xL3=[-41 -2 -2 -22];
yL3=[-186 -186 -164 -164];
xL=[xL1 xL2 xL3];
yL=[yL1 yL2 yL3];
plot(xL,yL,'k');
fill(xL,yL,'k');
%右边
xR1=[22 2 2 41];
yR1=[-164 -164 -186 -186];
theta=-pi/3:0.1:4*pi/9;%圆弧
xR2=37+8*cos(theta);
yR2=-179.07+8*sin(theta);
xR3=[22 22];
yR3=[-172 -164];
xR=[xR1 xR2 xR3];
yR=[yR1 yR2 yR3];
plot(xR,yR,'k');
fill(xR,yR,'k');

axis equal
axis off
% title('小黄人');
Released two original articles · won praise 0 · Views 52

Guess you like

Origin blog.csdn.net/qq_45384561/article/details/104244888