@techmely/utils
Version:
Collection of helpful JavaScript / TypeScript utils
27 lines (22 loc) • 598 B
JavaScript
/*!
* @techmely/utils
* Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com>
* MIT Licensed
*/
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
};