set_background_opacity.go 267 B

1234567891011121314
  1. // License: GPLv3 Copyright: 2022, Kovid Goyal, <kovid at kovidgoyal.net>
  2. package at
  3. import "strconv"
  4. func parse_opacity(arg string) (float64, error) {
  5. ans, err := strconv.ParseFloat(arg, 64)
  6. if err != nil {
  7. return 0, nil
  8. }
  9. return max(0, min(ans, 1)), nil
  10. }