• Remix
  • Share
  • New Entry

on 3 Dec 2023
  • 9
  • 128
  • 0
  • 1
  • 844
drawframe(1);
Title inspired by Shel Silverstein's A Light In The Attic.
Remix of my 2021 minihack entry A Time-Lapse of the Night Sky
Write your drawframe function below
function drawframe(f)
persistent h x y n wdw
rng default
if isempty(h) || f==1
% Dark sky
axes(Position=[0 0 1 1])
s = 99;
q=linspace(50,1,s);
hold on % hold before imagesc to keep ydir normal
imagesc(q'.*(q./q),[20,80])
% Add star rotation
td=0:0.001:.1; % theta delta
n=1000; % number of stars
theta = pi/1.8*rand(1,n)+pi-.1; % range: 180:270 +/- (quadrant III)
[x,y]=pol2cart(theta+td',rand(1,n).*s*sqrt(2));
x = x+s; % move polaris to the upper right corner
y = y+s; % move polaris to the upper right corner
h = plot(x, y,'color','w');
rgba = ones(n,4);
rgba(:,4) = rescale(randg(1,n,1),.1,1);
set(h,{'color'},mat2cell(rgba,ones(n,1),4))
% Add grassy hill
g = 1000; % number of grass blades
xg = linspace(0,s+1,g);
yg = cos(xg/(s+1))*30+randg(1,1,g);
area(xg,yg,FaceColor='k')
xg=[1,1:.1:s,s];
yg=[1,cos(0:.1/98:1)*30+randg(1,1,981),1];
fill(xg,yg,'k')
% Add house silhouette
fill([4 4 3 6 9 8 8]*5,[5 7 7 8 7 7 5]*5,'k')
% Add window
wdw=fill(30+2*[-1 1 1 -1],35+[2.2 2.2 .1 .1],[.1 .1 .1]);
camva(6)
axis equal off
xlim([1 s])
ylim([1 s])
colormap gray
end
k = round(f/48*height(x));
set(h,{'XData'},mat2cell(x(1:k,:),k,ones(1,n))',{'YData'},mat2cell(y(1:k,:),k,ones(1,n))')
if f==24
wdw.FaceColor = [0.6 0.6 0.4];
end
end
Animation
Remix Tree