• Remix
  • Share
  • New Entry

on 6 Nov 2023
  • 8
  • 23
  • 0
  • 3
  • 1354
drawframe(1);
Write your drawframe function below
function drawframe(f)
lineColor=[1 1 1]; alphaValue=0.25; colorMethod='solid'; pointColor=NaN; darkBackground=true;
if f==1
set(gca,'nextplot','replacechildren');
set(gcf, 'color', 'k')
% Clear the axes
cla
end
hold on
%% Compute modular arithmetic
numberOfPoints = 48;
multiplier = 146;
% Define center and radius
X = 0; Y = 0;
radius = 1;
% Fix the axis limits
xlim([-1.1 1.1]*radius)
ylim([-1.1 1.1]*radius)
% Plot the circle
a = linspace(0, 2*pi, 360*numberOfPoints); % Assign Angle Vector
xVec = X + radius.*cos(a); % Circle ‘x’ Vector
yVec = Y + radius.*sin(a);
% plot(xVec, yVec, 'color', [0 0 0]) % Plot Circle
% Set the axis aspect ratio to 1:1
axis square
axis off
% Indices of points locations
pointIndices = 1:360:360*numberOfPoints;
% Compute times table
pointsVecBegin = round(1:numberOfPoints);
pointsVecEnd = floor(mod(pointsVecBegin*multiplier, numberOfPoints)) + 1;
% Line opacity
alphaValue = repmat(alphaValue, [numberOfPoints 1]);
% Check if numberOfPoints > length(lineColor)
if isvector(lineColor)
lineColor = repmat(lineColor, [numberOfPoints 1]);
else
% Interpolate colormap to the required number of points
lineColor_interp = zeros(numberOfPoints, 3);
for iChannels = 1:3
lineColor_interp(:,iChannels) = interp1(1:size(lineColor,1), ...
lineColor(:, iChannels), linspace(1, size(lineColor,1),numberOfPoints));
end
lineColor = lineColor_interp;
end
lineColor = hsv(numberOfPoints);
% Plot Lines
hPlot = plot([xVec(pointIndices(pointsVecBegin(f))), ...
xVec(pointIndices(pointsVecEnd(f)))], ...
[yVec(pointIndices(pointsVecBegin(f))), ...
yVec(pointIndices(pointsVecEnd(f)))], '-', 'Color', lineColor(f,:));
hPlot.Color(4) = alphaValue(f);% Modify line opacity
hPlot.LineWidth = 1.5;
if ~isnan(pointColor)
% hPoint = plot(xVec(pointIndices), yVec(pointIndices), '.', 'Color', pointColor);
plot(xVec(pointIndices), yVec(pointIndices), '.', 'Color', pointColor);
end
% hPoint.Color(4) = alphaValue; % Does not change transparency...
myFontSize = 14;
% Add title
if darkBackground
titleColor = [1 1 1]; % White letters
else
titleColor = [0 0 0]; % Black letters
end
end
Animation
Remix Tree