- /
-
Kaonashi🎐
on 17 Oct 2024
- 31
- 271
- 1
- 9
- 1953
Cite your audio source here (if applicable):
% Audio - Joe Hisaishi - One Summer's Day
% https://youtu.be/TK1Ij_-mank?si=BUZmUtQwOPErYzPf
drawframe(1);
Write your drawframe function below
function drawframe(f)
% Kaonashi, which means “no-face” in Japanese, is a melancholic spirit
% that appears in the animated film Spirited Away.
% It exists without a sense of self and changes depending
% on the things and people it encounters.
% Kaonashi represents loneliness and abandonment.
figure('color','k')
hold on
% Setting up axis properties
axis off ;
axis equal;
xmin = -10 ; xmax = 10; ymin = -10 ; ymax = 10 ; len = xmax - xmin ;
axis([xmin xmax ymin ymax])
LW = 'LineWidth' ;
EC = 'EdgeColor' ;
% Setting up Gradient Background
gX = [xmin xmax xmax xmin];
gY = [ymin ymin ymax ymax];
cdata = [0.5 0.1 1; 0.7 0.3 0.8; 0 0.3 0.6; 0 0.4 0.9]; %Blue-Purple-Pink
patch(gX, gY, [1 2 3 4], 'FaceVertexCData', cdata, 'FaceColor', 'interp');
% Black Body
x = linspace(-4, 4, 100);
y = -(x/1.2).^2 + 7;
% Circle parameters : Bottom part of body
c = [0,-5];
r = 4 * sqrt(2);
th1 = linspace(-3*pi/4, -pi/4, 100);
% Parametric equations for the circle
xc = c(1) + r * cos(th1);
yc = c(2) + r * sin(th1);
% Filling the region below the curve y and above the circle
xReg = [xc, fliplr(x)];
yReg = [yc, fliplr(y)];
% Gradient Greyscale Coloring
n = length(xReg);
colors = [linspace(0.4, 0, n)', ...
linspace(0.4, 0, n)', ...
linspace(0.4, 0, n)'];
patch('XData', xReg, 'YData', yReg, 'FaceColor', 'interp', ...
'EdgeColor', 'none', 'FaceVertexCData', colors);
% White Face Mask
th = linspace(0, 2*pi, 100);
% Parameters
a = 1.7; % Semi-minor axis
b = 2.5; % Semi-major axis
c1 = [0, 4.5]; % Center of the ellipse
[x1,y1] = ellipse(a,b,c1(1),c1(2),th);
fill(x1, y1, 'w', 'EdgeColor','k', 'LineWidth', 6);
% Eyes
a1 = 0.4;
b1 = 0.15;
c2 = [-0.9, 4.8];
[x2,y2] = ellipse(a1,b1,c2(1),c2(2),th);
fill(x2, y2, 'k', -x2, y2, 'k')
% Arc below eyes
th2 = linspace(5*pi/4, 7*pi/4, 100);
[x3,y3] = ellipse(a1,b1,c2(1),4.65,th2);
plot(x3, y3, 'k',-x3, y3, 'k','linewidth',0.9)
% Mouth
a2 = 0.6;
b2 = 0.2;
c3 = [0, 3];
[x4,y4] = ellipse(a2,b2,c3(1),c3(2),th);
fill(x4, y4, 'k', EC, 'none');
% Arc below mouth
c4 = [0, 2.85];
[x5,y5] = ellipse(a2,b2,c4(1),c4(2),th2);
lav = [0.4 0.2 0.7]; % Lavender Color
plot(x5, y5,'color',lav, LW, 1.5);
% Purple stripes above eyes
a3 = 0.2;
b3 = 0.7;
c5 = [-0.9, 5.2];
th3 = linspace(0, pi, 100);
[x6,y6] = ellipse(a3,b3,c5(1),c5(2),th3);
fill(x6, y6, lav,-x6, y6, lav, EC, 'none');
% Purple stripes below eyes
th4 = linspace(pi, 2*pi, 100);
[x7,y7] = ellipse(a3,b3+0.2,c5(1),4.3,th4);
fill(x7, y7, lav,-x7, y7, lav, EC, 'none');
% Rain Scene
k = 100; %number of droplets
% Initializing x and y positions of the rain droplets within the axis range
xd = rand(1, k) * len + xmin;
yd = rand(1, k) * len + ymin;
% The Length of droplets
dL = 2;
% Rainfall speed
speed = 0.1;
% Initializing lines for rain droplets
h = gobjects(1, k); % preallocating array of graphics object
for i = 1:k
h(i) = line([xd(i) xd(i)], [yd(i) yd(i) + dL], 'Color', [1 1 1 0.4], LW, 0.7);
end
% Updating the y positions of the rain droplets
yd = yd - speed;
% If a droplet goes below ymin, resetting it to the top ymax
yd(yd < ymin) = ymax;
% Updating the positions of the lines
for i = 1:k
set(h(i), 'XData', [xd(i) xd(i)], 'YData', [yd(i) yd(i) + dL]);
end
end
function [x,y] = ellipse(a,b,cx,cy,th) %Create Ellipse
% Parametric equations of the ellipse
x = a * cos(th) + cx ;
y = b* sin(th) + cy ;
end