File: map_range_to_range.go

package info (click to toggle)
golang-github-pterm-pterm 0.12.79-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,640 kB
  • sloc: makefile: 4
file content (8 lines) | stat: -rw-r--r-- 210 bytes parent folder | download
1
2
3
4
5
6
7
8
package internal

func MapRangeToRange(fromMin, fromMax, toMin, toMax, current float32) int {
	if fromMax-fromMin == 0 {
		return 0
	}
	return int(toMin + ((toMax-toMin)/(fromMax-fromMin))*(current-fromMin))
}