'use strict';

/*!
 * @techmely/utils
 * Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com>
 * MIT Licensed
 */


// src/clamp.ts
function clamp(n, min, max) {
  return Math.min(max, Math.max(min, n));
}

// src/lerp.ts
function lerp(y1, y2, mu) {
  return y1 * (1 - mu) + y2 * mu;
}

// 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;
}

exports.getStrokeRadius = getStrokeRadius;
