Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Single-use Random vs. ofRandom

$
0
0

@JDeut wrote:

I’m not sure what the proper nomenclature is for this stuff, since I’m just learning - so please excuse my mislabeling for the time being.

My understanding is that ofRandom is a random function - and functions evaluate at frame rate within the draw() and update() functions.

I’m working with the “singleLightExample” in the examples folder - and part of the code uses a for loop:

for(int i = 0; i < numSpheres; i++) {
float angle = TWO_PI / (float)numSpheres * i;
float x = cos(angle) * radius;
float y = sin(angle) * radius;
ofDrawSphere(x, y, -200, sphereRadius);
}

I’d like to generate a random value for each sphereRadius, one time.

Is the best way to do this to somehow populate an array in the setup() function with one-time generated values and then find a way to feed them into the for loop?

Posts: 4

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles