Random
The random class provides a range of methods for producing random values.
The random object is instansiated for free:
const random = new Random()
// examples
random.int()
random.point()
Meta Data
| title | Random |
| dependencies | () |
| unused_keys | () |
| unknown_keys | () |
| filepath_exists | True |
| path | random |
| filepath | random.js |
| clean_files | () |
-
ClassDeclarationclass
Random
extends Noneclass comments:The minimum value the _point(value)_ can be, before the automatic 'float' method is used over the 'int' method.-
dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])return two random values between 0 and 1 multiplied by the given value `multiplier`. This is similar to the random.point() function, except it only returns an object of {x,y}
VariableDeclarationExpressionStatement:
dict_keys(['type', 'expression', 'pos'])VariableDeclarationPerform random() on the X and Y. If a point is given, randomize to the _max_ of the given point If a single number is given, assume _square_ If no params are given, discover the stage size. Use `Point.random()` for the same form, as a new point let p = new Point() p.randomize(100, 400) p.randomize(100) // 100, 100 p.randomize(new Point(100, 400)) // 100, 400 if one of the keys is undefined, no change occurs: p.setXY(500,700) p.randomize(100, undefined) // 100, 700 p.randomize(undefined, 400) // 500, 400 p.randomize(undefined, undefined) // 500, 700 // no change occurs. Note; no params will randomize as much as possible (the stage size) p.randomize() // 800, 600 Other features would be nice: + random in rect (like stage): p.randomize(rect|dimensions) + Randomize other values, e.g radius, colors p.randomize(['x', 'y', 'radius', 'mass']) // randomize x to max 400, radius to max 50 p.randomize({ x: 400, radius: 50}) + In the future, the _origin_; randomize relative to a point: p.randomize({point, relative: true})