• Remix
  • Share
  • New Entry

  • Charu Pande

  • /
  • Sunlit river dance with a sailing ship, dynamic clouds and birds

on 13 Nov 2023
  • 6
  • 9
  • 0
  • 0
  • 1632
function drawframe(f)
cla
f = 49 - f;
t = 0.03 + f / 300;
a = [1 2 3 4];
b = [1 2 3];
% sky
patch('Faces', [1 2 3 4], 'Vertices', [0 0; 1 0; 1 1; 0 1], 'FaceColor', [0.53, 0.81, 0.98]);
hold on
% sun with rays
sun_position = [0.5, 0.8];
plot(sun_position(1), sun_position(2), '.', 'markersize', 100, 'Color', [1, 0.8, 0])
% extend sun rays
num_rays = 12;
for angle = linspace(0, 2*pi, num_rays)
ray_end = sun_position + 0.1 * [cos(angle), sin(angle)];
line([sun_position(1), ray_end(1)], [sun_position(2), ray_end(2)], 'Color', [1, 0.8, 0], 'LineWidth', 1);
end
% clouds
for i = 1:f
cloud_x = rand() * 1;
cloud_y = rand() * 0.03 + 0.7;
plot(cloud_x, cloud_y, '.', 'markersize', 20, 'Color', [1, 1, 1])
end
% flowing river
river_x = 0:0.01:1;
flow_speed = 0.01; % Adjust the flow speed as needed
river_y = cos(10 * (river_x - flow_speed * f) * pi)/60 + 0.2; % Introduce time-dependent flow
line(river_x, river_y, 'Color', [0.12, 0.56, 1], 'LineWidth', 2);
% ship body
body_x = 0.5 + f / 200;
body_y = 0.25 ;
patch('Faces', a, 'Vertices', [body_x - 0.02, body_y; body_x + 0.02, body_y; body_x - 0.01, body_y + 0.05; body_x + 0.01, body_y + 0.05], 'FaceColor', 'b');
% ship windows
window_size = 0.005;
window_y = body_y + 0.025;
for i = -1:1
window_x = body_x + i * 0.012;
rectangle('Position', [window_x - window_size, window_y - window_size, 2 * window_size, 2 * window_size], 'Curvature', [1, 1], 'FaceColor', 'w', 'EdgeColor', 'k');
end
% arms
arm_length = 0.05;
arm_y = body_y;
patch('Faces', b, 'Vertices', [body_x - arm_length, arm_y; body_x, arm_y + 0.02; body_x + arm_length, arm_y], 'FaceColor', 'r');
patch('Faces', b, 'Vertices', [body_x - arm_length, arm_y; body_x, arm_y - 0.02; body_x + arm_length, arm_y], 'FaceColor', 'r');
% birds flying in the sky
bird_x = rand(1, 3);
bird_y = rand(1, 3) * 0.2 + 0.8;
plot(bird_x, bird_y, 'v', 'markersize', 2, 'Color', [0, 0, 0]);
xlim([0 1])
ylim([0 1])
axis off
end
Animation
Remix Tree