Clamping

main

A simple library for conveniently clamping values to ranges.
edonv/Clamping

Clamping

A simple library for conveniently clamping values to ranges.

Examples

let clamped1 = 25.clamped(to: 0...12) // = 12
let clamped2 = 10.clamped(to: 0...12) // = 10
let clamped3 = -10.clamped(to: 0...12) // = 0

let clamped4 = 25.clamped(to: 50...) // = 50
let clamped5 = 60.clamped(to: 50...) // = 60

let clamped6 = 25.clamped(to: ...50) // = 25
let clamped7 = 60.clamped(to: ...50) // = 50

Description

  • Swift Tools 5.7.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri Oct 18 2024 14:36:49 GMT-0900 (Hawaii-Aleutian Daylight Time)