- /
-
Whispers of the Ocean's Breeze
on 28 Oct 2024
- 15
- 237
- 0
- 2
- 1532
Cite your audio source here (if applicable): Klapa Sibenik (comp. Arsen Dedic) - Zaludu me svitovala mati (Croatia ðŸ‡ðŸ‡·, (Dalmatia))
drawframe(1);
Write your drawframe function below
function drawframe(f)
% Klapa Å ibenik (comp. Arsen Dedić) - Zaludu me svitovala mati (Hrvatska ðŸ‡ðŸ‡·, (Dalmacija))
% Enhanced aesthetics and added dynamic movement, offering a creative Remix of my earlier concept.
% (This version brings richer visual appeal, smoother transitions, and a more engaging animation flow)
seaweed(4) % The value in brackets can be adjusted for significantly enhanced visualization,
% but it exceeds the 235-second limit in the contest script.
% Feel free to experiment at Desktop workstation - with higher values in the loop,
% for more complex and beautiful results.
% Main function `seaweed` which initializes figure and starts recursive plotting
function seaweed(k)
% Set up the figure window with a specific position and background color
figure('Position',[60+2*f,60-2*f,600,600], 'Color', [0.15 0.15 0.5]);
% Begin recursive drawing with `crta`, starting at origin, 90-degree angle, and initial recursion depth `k`
crta([0,0], 90, k, k);
% Make the axes equal and turn them off for a clean figure
axis equal
axis off
% Recursive function `crta` to draw lines at various angles, simulating "seaweed" branches
function crta(tck, ugao, prstiter, r)
% Define thickness of line segment proportional to current depth
sir = 5 * (prstiter / r);
% Define length of the line segment
duz1 = 5 * prstiter;
% Define four branching angles with slight variations
ug1 = ugao + 15 + (f / 15);
ug2 = ugao + 7 - f / 15;
ug3 = ugao - 7 + f / 15;
ug4 = ugao - 15 - f / 15;
% Calculate endpoints of each line segment for the four angles
a1 = duz1 * sind(ug1) + tck(2);
b1 = duz1 * cosd(ug1) + tck(1);
c2 = duz1 * sind(ug2) + tck(2);
a2 = duz1 * cosd(ug2) + tck(1);
b3 = duz1 * sind(ug3) + tck(2);
c3 = duz1 * cosd(ug3) + tck(1);
d4 = duz1 * sind(ug4) + tck(2);
e4 = duz1 * cosd(ug4) + tck(1);
% Calculate midpoints for additional "leaves" to simulate complexity
uga1 = ug2 - 5 + f / 5;
ugb2 = ug3 + 5 - f / 5;
uga2 = duz1 / 2 * sind(uga1) + c2 + f / 20;
ugb3 = duz1 / 2 * cosd(uga1) + a2 - f / 20;
ugc2 = duz1 / 2 * sind(ugb2) + b3 + f / 20;
ugda1 = duz1 / 2 * cosd(ugb2) + c3 - f / 20;
% Define color based on depth, simulating a gradient effect as recursion deepens
boja = [1 - (prstiter / r), 1 - 0.5 * (prstiter / r), 0];
% Plot main branches from the starting point (tck) to the calculated endpoints with color and transparency
p1 = plot([tck(1), b1], [tck(2), a1], 'LineWidth', sir, 'Color', boja);
hold on
s2 = plot([tck(1), a2], [tck(2), c2], 'LineWidth', sir, 'Color', boja);
s3 = plot([tck(1), c3], [tck(2), b3], 'LineWidth', sir, 'Color', boja);
s4 = plot([tck(1), e4], [tck(2), d4], 'LineWidth', sir, 'Color', boja);
% Plot secondary branches connecting midpoints for added detail
s5 = plot([a2, ugb3], [c2, uga2], 'LineWidth', sir, 'Color', boja);
s6 = plot([c3, ugda1], [b3, ugc2], 'LineWidth', sir, 'Color', boja);
% Set transparency for each plot segment
s1.Color(4) = 0.95;
s2.Color(4) = 0.95;
s3.Color(4) = 0.95;
s4.Color(4) = 0.95;
s5.Color(4) = 0.95;
s6.Color(4) = 0.95;
% Continue recursive drawing if there are levels left (`prstiter` > 0)
if prstiter - 1 > 0
% Recursive calls for each of the main branches with updated angles and decreased recursion depth
crta([b1, a1], ug1, prstiter - 1, r);
crta([ugb3, uga2], uga1, prstiter - 1, r);
crta([ugda1, ugc2], ugb2, prstiter - 1, r);
crta([e4, d4], ug4, prstiter - 1, r);
end
end
end
end