UNPKG

@baby-journey/rn-segmented-progress-bar

Version:
35 lines 964 B
export const getPathValues = (progress, max, segments) => { if (!progress) { return [...Array(segments)].map(() => 0); } const pathLengths = []; if (progress > max) { progress = max; } progress = 100 * progress / max; let i = 0; while (i < segments) { const val = progress >= max / segments ? max / segments : progress; pathLengths.push(Number.parseFloat(val.toFixed(4))); progress = progress - val; i++; } return pathLengths; }; export const getArcEndCoordinates = function (radius, circleCircumference, cx, cy) { let rotation = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0; if (!circleCircumference || !radius || !cx || !cy) { return { x: 0, y: 0 }; } const θ = circleCircumference / radius + rotation * Math.PI / 180; const x = Math.cos(θ) * radius + cx; const y = Math.sin(θ) * radius + cy; return { x, y }; }; //# sourceMappingURL=index.js.map