Happy Birthday Animation with changing colors

์กฐํšŒ ์ˆ˜: 9(์ตœ๊ทผ 30์ผ)
Mohammad Ali
Mohammad Ali 2021๋…„ 4์›” 30์ผ
๋Œ“๊ธ€: Mohammad Ali 2021๋…„ 4์›” 30์ผ
I have found great animation example
But I want similar animation with changing colors of text and flower, with happy birthday message.
It will be great if script is changed to function for text and flower options

์ฑ„ํƒ๋œ ๋‹ต๋ณ€

Khalid Mahmood
Khalid Mahmood 2021๋…„ 4์›” 30์ผ
I hope this will be great example for you
function f=Animate(str,chr) %string that rotates along central character
if nargin<2
chr='๐ŸŒบ';%๐Ÿ•๐Ÿ•‘๐Ÿ•’๐Ÿ•“๐Ÿ•”๐Ÿ••๐Ÿ•–๐Ÿ•—๐Ÿ•˜ %char(9752)%flower=9752
if nargin<1
str='Happy Birthday!';
end
end
fig = figure('MenuBar','none','Color', [0 .4 .3],'Units','Normalized','Position',[.1 .1 .8 .8]); % Shamrock green
ax = axes(fig,'Units','Normalized','Position',[0 0 1 1]);
axis(ax,'off')
axis(ax,'equal')
hold(ax,'on')
xlim(ax,[-1,1]); ylim(ax,[-1,1])
text(ax, 0, 0, chr, 'VerticalAlignment','middle','HorizontalAlignment','center','FontSize', 400)
str = num2cell(str);
th = linspace(-pi/2,pi/2,numel(str));
txtHandle = text(ax,sin(th)*.8, cos(th)*.8, str, 'VerticalAlignment','middle','HorizontalAlignment','center','FontSize', 45);
set(txtHandle,{'rotation'}, num2cell(rad2deg(-th')))
thr = 0.017;
rotateCCW = @(xyz)([cos(thr) -sin(thr) 0; sin(thr), cos(thr), 0; 0 0 1]*xyz.').';
clr=[1 0 .1]; clrf=1-[clr];
t1=double(tic);fs=450;
while all(isvalid(txtHandle))
text(ax, 0, 0, chr, 'VerticalAlignment','middle','HorizontalAlignment','center','FontSize', fs,'Color',clrf)
newposition = rotateCCW(vertcat(txtHandle.Position));
set(txtHandle,'Color',clr,{'position'}, mat2cell(newposition,ones(numel(txtHandle),1),3), ...
{'rotation'}, num2cell([txtHandle.Rotation].'+thr*180/pi))
drawnow()
t2=double(tic);
if (t2-t1)/1e7>.25
clr=rand(1,3)/2;t1=t2;
if fs<350, fs=fs*1.2; else, fs=50;end
else
if all(clr)<.9,clr-clr*1.2;end
end
clrf=1-clr;
end
  ๋Œ“๊ธ€ ์ˆ˜: 1
Mohammad Ali
Mohammad Ali 2021๋…„ 4์›” 30์ผ
Thnaks a lot. It's perfect

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์ถ”๊ฐ€ ๋‹ต๋ณ€(1๊ฐœ)

Khalid Mahmood
Khalid Mahmood 2021๋…„ 4์›” 30์ผ
Like Following?
function f=Animate(str,chr) %string that rotates along central character
if nargin<2
chr='๐ŸŒบ';%๐Ÿ•๐Ÿ•‘๐Ÿ•’๐Ÿ•“๐Ÿ•”๐Ÿ••๐Ÿ•–๐Ÿ•—๐Ÿ•˜ %char(9752)%flower=9752
if nargin<1
str='Happy Birthday!';
end
end
fig = figure('MenuBar','none','Color', [0 .4 .3],'Units','Normalized','Position',[.1 .1 .8 .8]); % Shamrock green
ax = axes(fig,'Units','Normalized','Position',[0 0 1 1]);
axis(ax,'off')....
  ๋Œ“๊ธ€ ์ˆ˜: 1
Mohammad Ali
Mohammad Ali 2021๋…„ 4์›” 30์ผ
Yes, but complete it please

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

๋ฒ”์ฃผ

Find more on Call Python from MATLAB in Help Center and File Exchange

ํƒœ๊ทธ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by