- /
-
Toggle
on 7 Nov 2023
- 8
- 77
- 6
- 2
- 535
drawframe(24);
Write your drawframe function below
function drawframe(f)
% Background plot
figure('Position', [100, 100, 300, 300]);
set(gca, 'color', 'w', 'YTick', [], 'XTick', []);
axis([0 2 0 2]);
axis equal;
axis off
% Toogle background
color = [47, 126, 178]/255; % brand color
rectangle('Position', [0 0 2 1], 'Curvature', 1, 'FaceColor', color, 'EdgeColor', 'none');
text(0.26, 0.53, 'Yes', 'FontSize', 24, 'Color', 'w');
text(1.26, 0.53, 'No', 'FontSize', 24, 'Color', 'w');
% Inside toggle ease position
thumbRatio = 0.8;
x = (sin((f-1)/48 * 2*pi + pi/2) + 1) / 2; % generate the ease value postition
x = x + (1 - thumbRatio)/2; % reduce the size and shift it, so it doesn't touch the edges
rectangle('Position', [x 0.1 thumbRatio thumbRatio], 'Curvature', [1 1], 'FaceColor', 'w', 'EdgeColor', 'none');
end