Methods
CopyGridODEs(cols, rows, template)
Make a back-up of all the ODE states (for synchronous ODE updating)
Parameters:
Name | Type | Description |
---|---|---|
cols |
int | Width of the grid |
rows |
int | Height of the grid |
template |
2DArray | Get ODE states from here |
- Source:
MakeGrid(cols, rows, template)
Make a grid, or when a template is given, a COPY of a grid.
Parameters:
Name | Type | Description |
---|---|---|
cols |
int | Width of the new grid |
rows |
int | Height of the new grid |
template |
2DArray | Template to be used for copying (if not set, a new empty grid is made) |
- Source:
copy(aObject)
Deep copy function.
Parameters:
Name | Type | Description |
---|---|---|
aObject |
Object | Object to be deep copied. This function still won't deep copy every possible object, so when enabling deep copying, make sure you put your debug-hat on! |
- Source:
default_colours()
Compile a dict of default colours if nothing is given by the user. Reuses colours if more colours are needed.
- Source:
dict_reverse(obj)
Reverse dictionary
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | dictionary-style object to reverse in order |
- Source:
get2DFromCanvas(canvas) → {2DArray}
Reconstruct a 2D array based on a canvas
Parameters:
Name | Type | Description |
---|---|---|
canvas |
canvas | HTML canvas element to convert to a 2D grid for Cacatoo |
- Source:
Returns:
Returns a 2D array (i.e. a grid) with the states
- Type
- 2DArray
hexToRGB(hex)
Convert hexadecimal to RGB
Parameters:
Name | Type | Description |
---|---|---|
hex |
String | string to convert to RGB |
- Source:
nameToRGB(name)
Convert colour name to RGB
Parameters:
Name | Type | Description |
---|---|---|
name |
String | string to look up in the set of known colours (see below) |
- Source:
parseColours(cols)
Make sure all colours, even when of different types, are stored in the same format (RGB, as cacatoo uses internally)
Parameters:
Name | Type | Description |
---|---|---|
cols |
Array | array of strings, or [R,G,B]-arrays. Only strings are converted, other returned. |
- Source:
pause()
Below are a few global functions that are used by Simulation classes, but not a method of a Simulation instance per se
- Source:
random_colours()
A list of default colours if nothing is given by the user.
- Source:
shuffle(array, rng)
Randomly shuffle an array with custom RNG
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | array to be shuffled |
rng |
MersenneTwister | MersenneTwister RNG |
- Source:
stringToRGB(string)
Convert colour string to RGB. Works for colour names ('red','blue' or other colours defined in cacatoo), but also for hexadecimal strings
Parameters:
Name | Type | Description |
---|---|---|
string |
String | string to convert to RGB |
- Source: