• Remix
  • Share
  • New Entry

  • Claudia

  • /
  • Glowing spin-pause-spin

on 13 Nov 2023
  • 16
  • 35
  • 0
  • 1
  • 1964
Spinning segments with a pause between the sequences
function drawframe(f)
% draw the grid
g(0:DX*2:8*DY, 0:DY:DY*8);
hold on
g(DX:DX*2:8*DY, 10:DY:DY*8);
% compute what sequence to run, and adjust the frame value by adding a
% pause at the end of each set
if f <= 17
f = min(f, 13);
s = 1;
elseif f <= 25
f = min(f-4, 19);
s = 2;
elseif f <= 40
f = min(f-6, 31);
s = 3;
else
f = min(f-9, 37);
s = 4;
end
f = fmap(f);
% draw everything
pink(f, s);
green(f, s);
% axis adjustments
xlim([-10 150])
ylim([0 160])
set(gcf,'Color',[.1 .1 .1]);
axis off
hold off
end
% step of the X grid
function r = DX
r = sin(deg2rad(60)) * DY;
end
% step of the Y grid
function r = DY
r = 20;
end
% pink color
function r = P
r = [1 0 .5];
end
% green color
function r = G
r = [0 .9 .9];
end
% map the frame so that it fits in the available frames
function f = fmap(f)
f = (f-1)/6;
end
% given i and j return the XY coordiate, and shift the Y for alternative
% columns
function [x,y] = getXY(i,j)
x = i * DX;
y = j * DY + (mod(i, 2) == 1) * DY/2;
end
% draw the grid
function g(x, y)
[X, Y] = meshgrid(x, y);
scatter(X, Y, MarkerFaceColor=[.4 .4 .4], MarkerEdgeColor="none");
end
% draw a segment
function draw(i,j,k,cw,c)
[ox, oy] = getXY(i,j);
if cw == 0
k = 360 - k;
end
a = deg2rad(k);
x = [ox ox+sin(a)*DY];
y = [oy oy+cos(a)*DY];
scatter(ox, oy, MarkerFaceColor=c, MarkerEdgeColor="none");
for i = 4:-.5:1
patch(x, y, 'r', 'EdgeColor', c, 'EdgeAlpha', 0.1, 'LineWidth', i, 'FaceColor', 'none');
end
%plot(x,y, Color=c)
end
% draw all pink segments
function pink(f, s)
% loop for all the center points where the pink elements are placed
for c = [0 0 4 4 4 8 8;
2 6 0 4 8 2 6]
% define center and orientation for all sequences
if s == 1
p = [ones(1,6) * c(1);
ones(1,6) * c(2);
0:5];
else
p = [[-1 -1 0 0 1 1] + c(1);
[-1 0 -1 1 -1 0] + c(2);
[ 3 2 4 1 5 0] * (s == 2) + ...
[ 1 0 2 5 3 4] * (s == 3) + ...
[ 5 4 0 3 1 2] * (s == 4)];
end
% draw all segments
drawSet(p,f, 0, P);
end
end
% draw all green segments
function green(f,s)
% define point center and orientation for all sequences
if s == 1
p = [0 0 0 0 0 0 2 2 2 2 2 2 2 2 4 4 4 4 6 6 6 6 6 6 6 6 8 8 8 8 8 8 ;
0 0 4 4 8 8 1 1 3 3 5 5 7 7 2 2 6 6 1 1 3 3 5 5 7 7 0 0 4 4 8 8 ;
0 3 0 3 0 3 2 5 1 4 2 5 1 4 0 3 0 3 1 4 2 5 1 4 2 5 0 3 0 3 0 3 ];
elseif s == 4
p = [0 0 0 0 1 1 1 1 3 3 3 3 4 4 4 4 5 5 5 5 7 7 7 7 8 8 8 8;
1 3 5 7 1 2 5 6 0 3 4 7 1 3 5 7 0 3 4 7 1 2 5 6 1 3 5 7;
3 0 3 0 2 1 2 1 5 4 5 4 0 3 0 3 1 2 1 2 4 5 4 5 3 0 3 0];
else
p = [1 1 1 1 2 2 2 2 3 3 3 3 5 5 5 5 6 6 6 6 7 7 7 7;
0 3 4 7 2 4 6 8 1 2 5 6 1 2 5 6 0 2 4 6 0 3 4 7;
[5 3 5 3 4 1 4 1 2 0 2 0 3 5 3 5 4 1 4 1 0 2 0 2] * (s == 2) + ...
[0 4 0 4 5 2 5 2 3 1 3 1 4 0 4 0 5 2 5 2 1 3 1 3] * (s == 3)];
end
% draw all segments
drawSet(p,f, 1, G);
end
% draw all segments given point center and orientation, frame
% direction and color
function drawSet(p, f, d, c)
for i = p
draw(i(1), i(2), (f+i(3)) * 60, d, c)
end
end
Animation
Remix Tree