mirror of
https://github.com/processing/processing4.git
synced 2026-02-12 10:00:42 +01:00
67 lines
1.0 KiB
XML
67 lines
1.0 KiB
XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
<root>
|
|
<name>constrain()</name>
|
|
|
|
<category>Math</category>
|
|
|
|
<subcategory>Calculation</subcategory>
|
|
|
|
<usage>Web & Application</usage>
|
|
|
|
<example>
|
|
<image>constrain_.jar</image>
|
|
<code>
|
|
void loop()
|
|
{
|
|
background(204);
|
|
float mx = constrain(mouseX, 30, 70);
|
|
rect(mx-10, 40, 20, 20);
|
|
}
|
|
</code>
|
|
</example>
|
|
|
|
<description>
|
|
Constrains a value to not exceed a maximum and minimum value.
|
|
</description>
|
|
|
|
<syntax>
|
|
constrain(<c>value</c>, <c>min</c>, <c>max</c>)
|
|
</syntax>
|
|
|
|
<parameter>
|
|
<label>value</label>
|
|
<description>int or float: the value to constrain</description>
|
|
</parameter>
|
|
|
|
<parameter>
|
|
<label>min</label>
|
|
<description>int or float: minimum limit</description>
|
|
</parameter>
|
|
|
|
<parameter>
|
|
<label>max</label>
|
|
<description>int or float: maximum limit</description>
|
|
</parameter>
|
|
|
|
<returns>float or int (depending on the input values)</returns>
|
|
|
|
<related>
|
|
max()
|
|
min()
|
|
</related>
|
|
|
|
<availability>1.0</availability>
|
|
|
|
<type>Function</type>
|
|
|
|
<partof>PDE</partof>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</root>
|