• Remix
  • Share
  • New Entry

  • Charu Pande

  • /
  • Sun, Ship, and Clouds: A sunlit river dance

on 12 Nov 2023
  • 5
  • 18
  • 0
  • 0
  • 1257
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
plot(0.5, 0.8, '.', 'markersize', 100, 'Color', [1, 0.8, 0])
% 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');
xlim([0 1])
ylim([0 1])
axis off
end
Animation
Remix Tree