comparison libmlk-core/core/maths.c @ 288:cc0f02ae9005

core: add maths_scale function
author David Demelier <markand@malikania.fr>
date Thu, 07 Jan 2021 15:50:01 +0100
parents 8ef7fb7f14ad
children 196264679079
comparison
equal deleted inserted replaced
287:75d2fdf96064 288:cc0f02ae9005
24 return px > x && 24 return px > x &&
25 py > y && 25 py > y &&
26 px < x + (int)w && 26 px < x + (int)w &&
27 py < y + (int)h; 27 py < y + (int)h;
28 } 28 }
29
30 float
31 maths_scale(float in, float old_min, float old_max, float new_min, float new_max)
32 {
33 return (in / ((old_max - old_min) / (new_max - new_min))) + new_min;
34 }