UNPKG

@techmely/utils

Version:

Collection of helpful JavaScript / TypeScript utils

14 lines (11 loc) 482 B
import { lerp } from './chunk-Z7KOBSTB.mjs'; import { clamp } from './chunk-AN6UV2MK.mjs'; // src/getStrokeRadius.ts function getStrokeRadius(size, thinning, easing, pressure = 0.5) { if (!thinning) { return size / 2; } const newPressure = clamp(easing(pressure), 0, 1); return (thinning < 0 ? lerp(size, size + size * clamp(thinning, -0.95, -0.05), newPressure) : lerp(size - size * clamp(thinning, 0.05, 0.95), size, newPressure)) / 2; } export { getStrokeRadius };