UNPKG

m3-svelte

Version:

M3 Svelte implements the Material 3 design system in Svelte. See the [website](https://kendell.dev/m3-svelte/) for demos and usage instructions.

33 lines (32 loc) 980 B
const frequencyT = (Math.PI * 2) / 1000; const frequencyX = (Math.PI * 2) / 40; const round2 = (x) => Math.round(x * 100) / 100; const round1 = (x) => Math.round(x * 10) / 10; export const linear = (amp, center, from, to, time, softTo) => { time = time * frequencyT; time %= Math.PI * 2; if (from >= to) return ""; let path = ""; for (let xIterator = from; xIterator <= to; xIterator += 0.5) { const x = softTo ? Math.min(softTo, xIterator) : xIterator; const sinV = Math.sin(x * frequencyX + time); const y = sinV * amp + center; if (x == from) { path = `M ${round1(x)} ${round2(y)}`; } else { path += ` ${round1(x)} ${round2(y)}`; } } return path; }; export const trackOpacity = (right, x) => { let opacity = right - x; if (opacity < 0) opacity = 0; if (opacity > 1) opacity = 1; opacity = round2(opacity); return opacity; };