Need to have an OpenSesame expert by your side 24/7? Subscribe to Sigmund!
random functions (random-ext)
The random-ext
library is available as random
. This library provides many convenient, higher-level functions for randomization.
Example:
Draw eight circle with a random color and a location that is randomly sampled from a five by five grid:
let positions = xy_grid(5, 50)
positions = random.subArray(positions, 8)
const cnv = Canvas()
cnv.fixdot()
for (const [x, y] of positions) {
cnv.circle({x: x, y: y, r: 20, fill: true, color: random.color()})
}
cnv.show()
For an overview, see: