-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode2.m
89 lines (75 loc) · 2.03 KB
/
code2.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
close all
clear
clc
bg=imread('back2.png');% read background image
% bg=imread('中秋图片.jpg');% read background image
x0=[300 500 700 900];
y0=[150 150 150 150];% position of text
s0=[80 80 80 80];% size of text
r0=[0 0 0 0]; % rotation of text
txt=['中秋团圆'];
x_max=x0+10;
x_min=x0-10;
y_max=y0+10;
y_min=y0-10; % max and min position
s_max=s0+20;
s_min=s0-20; % max and min size
r_max=r0+20;
r_min=r0-20; % max and min rotation
cr_max=ones(1,4);
cg_max=ones(1,4);
cb_max=ones(1,4); % max of rgb
cr_min=[0.5 0.5 0.5 0.5];
cg_min=[0.5 0.5 0.5 0.5];
cb_min=zeros(1,4); % min of rgb
x=rand(1,4);
y=rand(1,4);
s=rand(1,4);
r=rand(1,4);
cr=rand(1,4);
cg=rand(1,4);
cb=rand(1,4); % initial rand number
while(1) % loop, never stop
x=x+0.2*rand(1,4)-0.1;
y=y+0.2*rand(1,4)-0.1;
s=s+0.2*rand(1,4)-0.1;
r=r+0.2*rand(1,4)-0.1;
cr=cr+0.2*rand(1,4)-0.1;
cg=cg+0.2*rand(1,4)-0.1;
cb=cb+0.2*rand(1,4)-0.1; %generate rand number
% equation:
% number = min_number + rand_number * (max_number - min_number)
% where rand_number is 0~1 and it changes smoothly
x(x>1)=1;
x(x<0)=0;
y(y>1)=1;
y(y<0)=0;
s(s>1)=1;
s(s<0)=0;
r(r>1)=1;
r(r<0)=0;
cr(cr>1)=1;
cr(cr<0)=0;
cg(cg>1)=1;
cg(cg<0)=0;
cb(cb>1)=1;
cb(cb<0)=0; % limit rand_number in 0~1
cla(gcf)
imshow(bg) % main function 1 imshow
hold on
for i=1:4;
text(x_min(i)+x(i)*(x_max(i)-x_min(i)),...
y_min(i)+y(i)*(y_max(i)-y_min(i)),...
txt(i),...
'FontSize',s_min(i)+s(i)*(s_max(i)-s_min(i)),...
'Rotation',r_min(i)+r(i)*(r_max(i)-r_min(i)),...
'Color',[cr_min(i)+cr(i)*(cr_max(i)-cr_min(i)),...
cg_min(i)+cg(i)*(cg_max(i)-cg_min(i)),...
cb_min(i)+cb(i)*(cb_max(i)-cb_min(i))],...
'FontName','黑体')
end % main function 2 text
xs=randi(1920,1,50);
ys=randi(1080,1,50);
plot(xs,ys,'LineStyle','none','Marker','x','MarkerSize',10,'MarkerEdgeColor',[1 1 rand]) % main function 3 plot
pause(0.01)
end