• Remix
  • Share
  • New Entry

on 22 Oct 2024
  • 25
  • 239
  • 0
  • 1
  • 1913
Cite your audio source here (if applicable):
drawframe(1);
Write your drawframe function below
function drawframe(f)
persistent th r ef spd clr
if isempty(th)
n=6; % Number of runners
r=linspace(7, 10, n); % Track radius for each runner
th=zeros(1, n); % Start all runners at theta = 0
ef=false; % End flag
spd=2*pi/96+rand(1,n)*0.002; % Randomized speeds for runners
clr=lines(n); % Colors for runners
end
clf;hold on; % Clear and hold figure
set(gca,'XLim',[-10, 10],'YLim',[-10, 10]); % Zoom in for 80% coverage
drTrk(); % Draw track
for i=1:length(th)
drHmn(r(i),th(i),f,clr(i,:)); % Draw each runner
end
th=th+spd; % Update positions
th=min(th,2*pi); % Cap positions to a full circle
drFlag(); % Draw Indian flag
drOlyText(); % Draw Olympics and India text
drOlyRings(); % Draw Olympic rings
drawnow; % Update figure
end
function drTrk()
th=linspace(0,2*pi,100); % Angular positions
lw=1; % Lane width
for rTrk=linspace(7,10,6) % Loop for lanes
xTrk=rTrk*cos(th);yTrk=rTrk*sin(th);
fill(xTrk,yTrk,[1, 0.7, 0.7]); % Track color
plot(xTrk,yTrk,'k','LineWidth',lw+1.5); % Thicker track lines
end
fill(6*cos(th),6*sin(th),'g'); % Green inner circle
for rLn=linspace(7,10,6) % Lane lines
plot(rLn*cos(th),rLn*sin(th),'w','LineWidth',lw); % White lane lines
end
% Start/Finish line on the right (90 degrees)
line([7, 10], [0, 0],'Color','r','LineWidth',4); % Finish line at 0 degrees
axis equal; axis off;
end
function drHmn(r, th, f, clr)
x = r * cos(th); y = r * sin(th);
hdY = 0.4; % Head Y-offset
aX = [-0.2 + 0.1 * sin(f * 0.2), 0.2 - 0.1 * sin(f * 0.2)];
lY = [-0.3 + 0.2 * sin(f * 0.2), -0.3 - 0.2 * sin(f * 0.2)];
% Body
plot([x,x],[y,y+hdY],'Color',clr,'LineWidth',3);
plot([x,x+aX(1)],[y+0.3,y+0.5],'Color',clr,'LineWidth',3); % Left arm
plot([x,x+aX(2)],[y+0.3,y+0.5],'Color',clr,'LineWidth',3); % Right arm
plot([x,x-0.2],[y,y+lY(1)],'Color',clr,'LineWidth',3); % Left leg
plot([x,x+0.2],[y,y+lY(2)],'Color',clr,'LineWidth',3); % Right leg
% Head
viscircles([x,y+hdY+0.2],0.2,'EdgeColor','k');
end
function drFlag()
xF=[-0.6,0.6,0.6,-0.6];yF=[0.6,0.6,0,0];
fill(xF, yF - 3, [1, 0.6, 0]); % Saffron (0.2 height step)
fill(xF, yF - 3.2, [1, 1, 1]); % White
fill(xF, yF - 3.3, [0, 1, 0]); % Green
viscircles([0, -2.9], 0.1, 'EdgeColor','b','LineWidth',2); % Ashoka Chakra
end
function drOlyText()
% Olympics 2036 and India text
text(0, -4.5, 'India','FontSize',15,'Color','r','FontWeight','bold','HorizontalAlignment','center');
text(0, -1.5, 'Olympics 2036','FontSize',17,'Color','w','FontWeight','bold','HorizontalAlignment','center');
end
function drOlyRings()
% Positions for Olympic rings (3 top, 2 bottom)
xOffsets = [-3, 0, 3]; % X offsets for the top row
yOffsets = [0, 0, 0]; % Y positions (top row)
xOffsets2 = [-1.5, 1.5]; % X offsets for the bottom row
yOffsets2 = [-1.5, -1.5]; % Y positions (bottom row)
rad = 1.2; % Ring radius
colors = {'b', 'y', 'k', 'g', 'r'}; % Ring colors
% Draw the 5 Olympic rings
for i = 1:3 % Top row (3 rings)
viscircles([xOffsets(i), 3], rad, 'EdgeColor', colors{i}, 'LineWidth', 3);
end
for i = 4:5 % Bottom row (2 rings)
viscircles([xOffsets2(i-3), 1.5], rad, 'EdgeColor', colors{i}, 'LineWidth', 3);
end
end
Movie
Audio
Remix Tree