- /
-
Happy Diwali - Lighting a Diya
on 24 Oct 2024
- 10
- 157
- 0
- 0
- 1053
Cite your audio source here (if applicable): Sound Effect by <a href="https://pixabay.com/users/alice_soundz-44907632/?utm_source=link-attribution&utm_medium=referral&utm_campaign=music&utm_content=224089">Alice_soundz</a> from <a href="https://pixabay.com//?utm_source=link-attribution&utm_medium=referral&utm_campaign=music&utm_content=224089">Pixabay</a>
drawframe(10);
Write your drawframe function below
function drawframe(f)
clf;
t = f/6;
set(gcf, 'Color', 'w'); % Set background color to white
hold on; % Hold on to plot multiple shapes
% Set axis limits and aspect ratio
axis equal; % Equal scaling
xlim([-10 10]); % X-axis limits
ylim([-10 10]); % Y-axis limits
% Hide axes
axis off;
% Define parameters for the circle
radius = 5; % Radius of the circle
theta = linspace(0, -pi, 99); % Angle from 0 to -pi
% Define the coordinates for the circle
x_circle = radius * cos(theta) - 5; % X coordinates
y_circle = radius * sin(theta); % Y coordinates
% Fill the circle using the fill function with brown color
brown_color = [0.65, 0.4, 0.4]; % RGB triplet for brown
fill(x_circle, y_circle, brown_color, 'EdgeColor', 'k'); % Brown color with black edges
flmClr = [1, rand(), 0]; % Random orange to red gradient for flame
% match stick movement and diya flame size
if f<48
x_line_coord = linspace(12-t, 8-t, 99);
y_line_coord = linspace(-4, 0, 99);
diya_flm_height = 0.1*rand()+0.1;
diya_flm_width = 0.1*rand()+0.1;
else
x_line_coord = linspace(6, 2, 99);
y_line_coord = linspace(-4, 0, 99);
diya_flm_height = 5*rand();
diya_flm_width = 2*rand();
text(-2, 7, 'Happy Diwali !', 'FontSize', t, 'Color', flmClr);
end
%match stick
fill(x_line_coord, y_line_coord, brown_color, 'EdgeColor', [0.5, 0.5, 0.5],'LineWidth',4); % Brown color with black edges
%match stick flame
flm_x_left = x_line_coord(end)-0.25;
flm_y_left = y_line_coord(end)+0.25;
flm_height = rand()+1; % Random height for flm
flm_width = rand() * 0.1 + 0.2; % Random width for flm
fill([flm_x_left - flm_width, flm_x_left + flm_width, flm_x_left], ...
[flm_y_left, flm_y_left, flm_y_left + flm_height], ...
flmClr);
%Diya flame
fill([-diya_flm_width, diya_flm_width, 0], ...
[0, 0, diya_flm_height], ...
flmClr);
hold off; % Release the hold on the current figure
end