Clamp¶
Name | Mandatory | Description | Default | Type |
---|---|---|---|---|
⬅️ Input |
The value to clamp. | Int Int2 Int3 Int4 Int8 Int16 Float Float2 Float3 Float4 Color |
||
Output ➡️ |
The clamped value. | Int Int2 Int3 Int4 Int8 Int16 Float Float2 Float3 Float4 Color |
||
Min |
No | The lower bound of the range | none |
Int Var(Int) Int2 Var(Int2) Int3 Var(Int3) Int4 Var(Int4) Int8 Var(Int8) Int16 Var(Int16) Float Var(Float) Float2 Var(Float2) Float3 Var(Float3) Float4 Var(Float4) Color Var(Color) [Any] Var([Any]) |
Max |
No | The upper bound of the range | none |
Int Var(Int) Int2 Var(Int2) Int3 Var(Int3) Int4 Var(Int4) Int8 Var(Int8) Int16 Var(Int16) Float Var(Float) Float2 Var(Float2) Float3 Var(Float3) Float4 Var(Float4) Color Var(Color) [Any] Var([Any]) |
This shard ensures the input value falls within the specified range. If the value falls below the minimum, the Min value is returned. If the value exceeds the maximum, the Max value is returned. Otherwise, the value is returned unchanged.
Details¶
This shard can accept integer or float vectors as input.
The input type and the type provided in the Min
and Max
parameters must be the same. (eg. if the input is a vector, the Min
and Max
parameters must be a vector of the same type)
The input vector and the Min
and Max
vector must be of the same length.
If the shard is comparing vectors, it will clamp each corresponding element in the input vector with the corresponding element in the Min
and Max
.
Consider the following example:
@i2(2 5)
Clamp(Min: @i2(3 3) Max: @i2(4 4))
Log("Result")
@i2(3 4)
. The first element in the input vector is 2, which is less than the first element in the Min
vector (3), so it is clamped to 3. The second element in the input vector is 5, which is greater than the second element in the Max
vector (4), so it is clamped to 4. It will process the Min
parameter first and then the Max
parameter.