Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
46 views

Random - Language (API) - Processing 3+

The document provides documentation for the random() function in Processing, including its syntax, parameters, return value, examples, and description. The random() function returns random numbers within a specified range, and can be used to add randomness to programs.

Uploaded by

insomnium1227
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Random - Language (API) - Processing 3+

The document provides documentation for the random() function in Processing, including its syntax, parameters, return value, examples, and description. The random() function returns random numbers within a specified range, and can be used to add randomness to programs.

Uploaded by

insomnium1227
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

5/6/2020 random() \ Language (API) \ Processing 3+

Processing p5.js Processing.py Processing for Android Processing for Pi Processing Foundation

Cover This reference is for Processing 3.0+. If you have a previous version, use the reference included with your
software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a
Download more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.
Donate

Exhibition Name random()


Reference
Examples for (int i = 0; i < 100; i++) {
Libraries float r = random(50);
stroke(r*5);
Tools line(50, i, 50+r, i);
Environment }

Tutorials
Examples
for (int i = 0; i < 100; i++) {
Books float r = random(-50, 50);
println(r);
Overview }
People

» Forum
» GitHub // Get a random element from an array
String[] words = { "apple", "bear", "cat", "dog" };
» Issues int index = int(random(words.length)); // Same as int(random(4))
» Wiki println(words[index]); // Prints one of the four words

» FAQ
» Twitter
» Facebook
Description Generates random numbers. Each time the random() function is called, it returns an
» Medium
unexpected value within the specified range. If only one parameter is passed to the function, it
will return a float between zero and the value of the high parameter. For example, random(5)
returns values between 0 and 5 (starting at zero, and up to, but not including, 5).

If two parameters are specified, the function will return a float with a value between the two
values. For example, random(-5, 10.2) returns values starting at -5 and up to (but not
including) 10.2. To convert a floating-point random number to an integer, use the int()
function.

Syntax random(high)
random(low, high)

Parameters low float: lower limit

high float: upper limit

Returns float

Related randomSeed()
noise()

https://processing.org/reference/random_.html 1/2
5/6/2020 random() \ Language (API) \ Processing 3+
Updated on January 9, 2020 00:33:09pm EST

Processing is an open project intiated by Ben Fry and Casey Reas. It is developed by a team of volunteers.
© Info

https://processing.org/reference/random_.html 2/2

You might also like