- /
-
Industrial Spider
on 17 Oct 2024
- 20
- 124
- 1
- 0
- 902
Cite your audio source here (if applicable):
Audio composed by Luke! and used with permission without much attribution.
set(gcf,'pos',[10 10 600 600]);
drawframe(1);
Write your drawframe function below
function drawframe(f)
cycle=12;
theta=linspace(0,2,20);
rset=linspace(.2,1,9);
ring=ceil(f/cycle);
ridx=[ 3 4 5 6 7 6 5 4 ];
k=ridx(ring);
r={ rset(1:(k-1) )
rset(k)
rset((k+1):9) };
dir=[-1 0 1
1 0 -1
-1 0 1
1 0 -1];
V = [ 0 0 ];
rot = mod(f,cycle)/cycle;
for idx=1:3
[R,T]=meshgrid(r{idx},theta(2:end)+dir(1,idx)*rot*theta(2));
X=cospi(T).*R;
Y=sinpi(T).*R;
V=[ V %#ok
X(:) Y(:)];
end
%% Compute the voronoi
T = delaunayTriangulation(rmmissing(V));
[ V, r ] = voronoiDiagram(T);
n = numel(r);
F=nan(n,12);
for q=1:n
if size(F,2) < numel(r{q})
for fi = (size(F,2)+1):numel(r{q})
F(:,fi) = nan;
end
end
F(q,1:numel(r{q}))=r{q};
end
FVC = hypot(V(:,1),V(:,2));
%% Upate patch
newplot
patch('Vertices',V,'Faces',F,'FaceVertexCData',FVC, ...
'FaceColor','none','EdgeColor','interp',...
'LineStyle', '-', 'LineWidth',3,'Marker','.');
text(0,0,'🕷','fontsi',56,'hor','cent','color','#f55','rot',180);
daspect([1 1 1]);
axis([-1 1 -1 1],'off');
set(gca,'position',[0 0 1 1]);
set(gcf,'color','k');
colormap(parula)
end