Clamp

clampMicronode

Holds a number inside an interval, returning the nearer bound when it falls outside. Folded at compile time: the result is spliced into the surrounding text as characters, so no node reaches the renderer and the number cannot be re-formatted, animated or bound to afterwards.

Explained in:Value primitives

#Attributes

toRequiredImplicit
interval
The interval the value is held inside, written from..to.Can be written as shorthand: clamp:value

#Allowed content

Body { }A number

#Examples

!clamp:0..1{1.4}

#Notes

  • !clamp:0..1{1.4} folds to 1; !clamp:0..1{-0.3} to 0; a value already inside the interval is unchanged.