ProtoFlux:Clamp 01: Difference between revisions

From Resonite Wiki
add clamp01
 
style, fixup
 
(6 intermediate revisions by 4 users not shown)
Line 12: Line 12:
|}}
|}}


Will camp the provided value between 0 and 1.
{{#invoke:Plotter|Plot2D
|From=-1.1, 0
|To=2.1, 1.1
|Plots=
[
{"Type": "function", "Function": "x", "Samples": 2, "Label": "*", "Ranges":[{"From": "0", "To": "1"}]},
{"Type": "function", "Function": "0", "Samples": 2, "Color": 1, "Ranges":[{"To": "0"}]},
{"Type": "function", "Function": "1", "Samples": 2, "Color": 1, "Ranges":[{"From": "1"}]}
]
}}
 
The '''Clamp 01''' node clamps the provided numeric value between 0 and 1.
 
== Inputs ==
 
=== N (Generic) ===
A numeric value.
 
== Outputs ==
 
=== * (Generic) ===
The input value, with the following conditions:
 
# If <code>N &lt; 0</code>, output <code>0</code>
# If <code>N &gt; 1</code>, output <code>1</code>
# Otherwise, output <code>N</code>
 
In the case of types with multiple values, each individual value will be clamped.
 
== Examples ==
<gallery widths=400px heights=400px>
File:Protoflux example clamp 01.webp|Four examples of the Clamp 01 node.
</gallery>
 
== See Also ==
* [[ProtoFlux:Value Clamp]], for clamping between arbitrary bounds.


[[Category:ProtoFlux:Math]]
[[Category:ProtoFlux:Math]]

Latest revision as of 19:45, 8 July 2024

Clamp01
N
*
Math
0 1 2 -1 1
*

The Clamp 01 node clamps the provided numeric value between 0 and 1.

Inputs

N (Generic)

A numeric value.

Outputs

* (Generic)

The input value, with the following conditions:

  1. If N < 0, output 0
  2. If N > 1, output 1
  3. Otherwise, output N

In the case of types with multiple values, each individual value will be clamped.

Examples

See Also