From 3de2a5872fd0481568e918a1ea798b3f75ace610 Mon Sep 17 00:00:00 2001 From: julian laplace Date: Wed, 26 Oct 2022 16:01:28 +0200 Subject: update keyword hover colors --- public/assets/js/util/format.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'public/assets/js/util/format.js') diff --git a/public/assets/js/util/format.js b/public/assets/js/util/format.js index 7058cea..aac8311 100644 --- a/public/assets/js/util/format.js +++ b/public/assets/js/util/format.js @@ -282,9 +282,18 @@ const size_scale = [ function get_size_opacity(n) { return get_scale_opacity(n, size_scale); } +/** + * find a value on one axis of an array of points, and return the proportional point + * @param {Array} value a value, to be matched on the first column of scale + * @param {Array} scale an array of points: (value, target) + * @return {Number} a proportional point within the closest target values + */ function get_scale_opacity(value, scale) { for (let i = 1; i < scale.length; i++) { const [max_value, max_lerp] = scale[i]; + if (value === max_value) { + return max_lerp; + } if (value < max_value) { const [min_value, min_lerp] = scale[i - 1]; return lerp(norm(value, min_value, max_value), min_lerp, max_lerp); -- cgit v1.2.3-70-g09d2