mirror of
https://github.com/processing/processing4.git
synced 2026-02-12 01:50:44 +01:00
72 lines
1.5 KiB
XML
72 lines
1.5 KiB
XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
<root>
|
|
<name>random()</name>
|
|
|
|
<category>Math</category>
|
|
|
|
<subcategory>Random</subcategory>
|
|
|
|
<usage>Web & Application</usage>
|
|
|
|
<example>
|
|
<image>random_.jar</image>
|
|
<code>
|
|
for(int i=0; i<100; i++) {
|
|
float r = random(50);
|
|
stroke(r*5);
|
|
line(50, i, 50+r, i);
|
|
}
|
|
</code>
|
|
</example>
|
|
|
|
<example>
|
|
<image>random_2.jar</image>
|
|
<code>
|
|
for(int i=0; i<100; i++) {
|
|
float r = random(-50, 50);
|
|
stroke(abs(r*5));
|
|
line(50, i, 50+r, i);
|
|
}
|
|
</code>
|
|
</example>
|
|
|
|
<description>
|
|
Generates random numbers. Each time the <b>random()</b> function is called, it returns an unexpected value within the specified range. If one parameter is passed to the function it will return a <b>float</b> between zero and the value of the parameter. The function call <b>random(5)</b> returns values between 0 and 5. If two parameters are passed, it will return a <b>float</b> with a value between the the parameters. The function call <b>random(-5, 10.2)</b> returns values between -5 and 10.2. To convert a floating-point random number to an integer, use the <b>int()</b> function.
|
|
</description>
|
|
|
|
<syntax>
|
|
random(<c>value1</c>);
|
|
random(<c>value1</c>, <c>value2</c>);
|
|
</syntax>
|
|
|
|
<parameter>
|
|
<label>value1</label>
|
|
<description>int or float</description>
|
|
</parameter>
|
|
|
|
<parameter>
|
|
<label>value2</label>
|
|
<description>int or float</description>
|
|
</parameter>
|
|
|
|
<returns>float</returns>
|
|
|
|
<related>
|
|
noise()
|
|
</related>
|
|
|
|
<availability>1.0</availability>
|
|
|
|
<type>Function</type>
|
|
|
|
<partof>Core</partof>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</root>
|