All files / atoms/SplitLoader utils.ts

100% Statements 12/12
100% Branches 0/0
100% Functions 1/1
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41    1x           1x           1x     10x 10x   10x 10x   10x 10x   10x 10x   10x                      
import { SplitLoaderSize } from './SplitLoader.types';
 
export const strokeWidthMap: Record<SplitLoaderSize, number> = {
  small: 3,
  medium: 4,
  large: 5,
};
 
export const gapWidthMap: Record<SplitLoaderSize, number> = {
  small: 30,
  medium: 35,
  large: 40,
};
 
export const radius = 45;
 
export function calculateLoaderSize(gapRadians: number) {
  const startX1 = 50 + radius * Math.cos(-Math.PI / 2 + gapRadians / 2);
  const startY1 = 50 + radius * Math.sin(-Math.PI / 2 + gapRadians / 2);
 
  const endX1 = 50 + radius * Math.cos(Math.PI / 2 - gapRadians / 2);
  const endY1 = 50 + radius * Math.sin(Math.PI / 2 - gapRadians / 2);
 
  const startX2 = 50 + radius * Math.cos(Math.PI / 2 + gapRadians / 2);
  const startY2 = 50 + radius * Math.sin(Math.PI / 2 + gapRadians / 2);
 
  const endX2 = 50 + radius * Math.cos((3 * Math.PI) / 2 - gapRadians / 2);
  const endY2 = 50 + radius * Math.sin((3 * Math.PI) / 2 - gapRadians / 2);
 
  return {
    startX1,
    startY1,
    endX1,
    endY1,
    startX2,
    startY2,
    endX2,
    endY2,
  };
}