DynamicGridsInteract.jl
DynamicGridsInteract.DynamicGridsInteract
— ModuleDynamicGridsInteract
DynamicGridsInteract provides web interfaces for visualising and interacting with simulations from DynamicGrids.jl, and for packages that build on it like Dispersal.jl.
The basic InteractOutput
works in the atom plot pane and Jupyter notebooks, and also serves as the core component of other outputs. A Mux.jl web server ServerOutput
and a Blink.jl electron app ElectronOutput
are also included.
This demo shows the InteractOutput
running it the atom IDE:
To use:
using DynamicGrids, DynamicGridsInteract
output = InteractOutput(init;
ruleset=ruleset,
tspan=1:100,
processor=ColorProcessor()
)
display(output)
Where init
is the initial array(s) for the simulation and ruleset is the Ruleset
to run in simulations.
To show the interface in the Atom plot pane, run display(output)
.
Interactive parameters
The interface provides control of the simulation using ModelParameters.jl and Interact.jl via InteractModels.jl. It will automatically generate sliders for every ModelParameters.Param
parameter in the Ruleset
, given they additionally have either a range
(an AbstractRange
) or bounds
(a Tuple
) field defined.
See the examples in the InteractModels.jl docs.
DynamicGridsInteract.AbstractInteractOutput
— TypeAbstractInteractOutput
Abstract supertype of Interact outputs including InteractOuput
and ElectronOutput
DynamicGridsInteract.ElectronOutput
— TypeElectronOutput <: AbstractInteractOutput
ElectronOutput(init; ruleset, tspan, kw...)
A html output using Interact.jl and an Electron window through Blink.jl ElectronOutput automatically generates sliders to control simulations in realtime. args and kwargs are passed to InteractOutput
.
Arguments
init
: initialisationAbstractArray
orNamedTuple
ofAbstractArray
.
Keywords
ruleset::Ruleset
: the ruleset to run in the interface simulations.
DynamicGrids.Extent
keywords:
init
: initialisationArray
/NamedTuple
for grid/s.mask
:BitArray
for defining cells that will/will not be run.aux
: NamedTuple of arbitrary input data. Useaux(data, Aux(:key))
to access from aRule
in a type-stable way.padval
: padding value for grids with neighborhood rules. The default iszero(eltype(init))
.tspan
: Time span range. Never type-stable, only access this inmodifyrule
methods
An Extent
object can be also passed to the extent
keyword, and other keywords will be ignored.
DynamicGrids.GraphicConfig
keywords:
fps::Real
: Frames per second.store::Bool
: Whether to store frames likeArrayOutput
or to disgard them after visualising. Very long simulation runs may fill available memory whenstore=true
.
A GraphicConfig
object can be also passed to the graphicconfig
keyword, and other keywords will be ignored.
DynamicGrids.ImageConfig
keywords:
minval
: Minimum value in the grid(s) to normalise for conversion to an RGB pixel. AVector/Matrix
for multiple grids, matching thelayout
array. Note: The default is0
, and will not be updated automatically for the simulation.maxval
: Maximum value in the grid(s) to normalise for conversion to an RGB pixel. AVector/Matrix
for multiple grids, matching thelayout
array. Note: The default is1
, and will not be updated automatically for the simulation.font
:String
name of font to search for. A default will be guessed.text
:TextConfig()
ornothing
for no text. Default isTextConfig(; font=font)
.scheme
: a ColorSchemes.jl colorscheme,ObjectScheme
or object that definesBase.get(obj, val)
and returns aColor
or a value that can be converted toColor
usingARGB32(val)
.zerocolor
: aCol
to use when values are zero, ornothing
to ignore.maskcolor
: aColor
to use when cells are masked, ornothing
to ignore.renderer
:Renderer
likeImage
orLayout
. Will be detected automatically, and usescheme
,zerocolor
andmaskcolor
keywords if available. Can be aVector/Matrix
for multiple grids, matching thelayout
array.
(See DynamicGrids.jl docs for more details)
DynamicGridsInteract.InteractOutput
— TypeInteractOutput <: AbstractInteractOutput
InteractOutput(init; ruleset, kw...)
An Output
for Atom/Juno and Jupyter notebooks, and the back-end for ElectronOutput
and ServerOutput
.
Arguments:
init
: initialisationAbstractArray
orNamedTuple
ofAbstractArray
.
Keywords
ruleset::Ruleset
: the ruleset to run in the interface simulations.
DynamicGrids.Extent
keywords:
init
: initialisationArray
/NamedTuple
for grid/s.mask
:BitArray
for defining cells that will/will not be run.aux
: NamedTuple of arbitrary input data. Useaux(data, Aux(:key))
to access from aRule
in a type-stable way.padval
: padding value for grids with neighborhood rules. The default iszero(eltype(init))
.tspan
: Time span range. Never type-stable, only access this inmodifyrule
methods
An Extent
object can be also passed to the extent
keyword, and other keywords will be ignored.
DynamicGrids.GraphicConfig
keywords:
fps::Real
: Frames per second.store::Bool
: Whether to store frames likeArrayOutput
or to disgard them after visualising. Very long simulation runs may fill available memory whenstore=true
.
A GraphicConfig
object can be also passed to the graphicconfig
keyword, and other keywords will be ignored.
DynamicGrids.ImageConfig
keywords:
minval
: Minimum value in the grid(s) to normalise for conversion to an RGB pixel. AVector/Matrix
for multiple grids, matching thelayout
array. Note: The default is0
, and will not be updated automatically for the simulation.maxval
: Maximum value in the grid(s) to normalise for conversion to an RGB pixel. AVector/Matrix
for multiple grids, matching thelayout
array. Note: The default is1
, and will not be updated automatically for the simulation.font
:String
name of font to search for. A default will be guessed.text
:TextConfig()
ornothing
for no text. Default isTextConfig(; font=font)
.scheme
: a ColorSchemes.jl colorscheme,ObjectScheme
or object that definesBase.get(obj, val)
and returns aColor
or a value that can be converted toColor
usingARGB32(val)
.zerocolor
: aCol
to use when values are zero, ornothing
to ignore.maskcolor
: aColor
to use when cells are masked, ornothing
to ignore.renderer
:Renderer
likeImage
orLayout
. Will be detected automatically, and usescheme
,zerocolor
andmaskcolor
keywords if available. Can be aVector/Matrix
for multiple grids, matching thelayout
array.
(See DynamicGrids.jl docs for more details)
DynamicGridsInteract.ServerOutput
— TypeServerOutput(init; port=8080, rulset, tspan, kw...)
A basic Mux.jl webserver, serving a InteractOutput
s to the web.
Unlike ElectronOutput
, the parameter modifications are not written back to the original rulset, and the simulations are not stored. Each page load gets a newly initialised Rulset.
Arguments
init
: initialisationArray
orNamedTuple
ofArray
Keyword arguments
port
: port number to reach the server.8080
by default, found atlocalhost:8080
.ruleset::Ruleset
: the ruleset to run in the interface simulations.
DynamicGrids.Extent
keywords:
init
: initialisationArray
/NamedTuple
for grid/s.mask
:BitArray
for defining cells that will/will not be run.aux
: NamedTuple of arbitrary input data. Useaux(data, Aux(:key))
to access from aRule
in a type-stable way.padval
: padding value for grids with neighborhood rules. The default iszero(eltype(init))
.tspan
: Time span range. Never type-stable, only access this inmodifyrule
methods
An Extent
object can be also passed to the extent
keyword, and other keywords will be ignored.
DynamicGrids.GraphicConfig
keywords:
fps::Real
: Frames per second.store::Bool
: Whether to store frames likeArrayOutput
or to disgard them after visualising. Very long simulation runs may fill available memory whenstore=true
.
A GraphicConfig
object can be also passed to the graphicconfig
keyword, and other keywords will be ignored.
DynamicGrids.ImageConfig
keywords:
minval
: Minimum value in the grid(s) to normalise for conversion to an RGB pixel. AVector/Matrix
for multiple grids, matching thelayout
array. Note: The default is0
, and will not be updated automatically for the simulation.maxval
: Maximum value in the grid(s) to normalise for conversion to an RGB pixel. AVector/Matrix
for multiple grids, matching thelayout
array. Note: The default is1
, and will not be updated automatically for the simulation.font
:String
name of font to search for. A default will be guessed.text
:TextConfig()
ornothing
for no text. Default isTextConfig(; font=font)
.scheme
: a ColorSchemes.jl colorscheme,ObjectScheme
or object that definesBase.get(obj, val)
and returns aColor
or a value that can be converted toColor
usingARGB32(val)
.zerocolor
: aCol
to use when values are zero, ornothing
to ignore.maskcolor
: aColor
to use when cells are masked, ornothing
to ignore.renderer
:Renderer
likeImage
orLayout
. Will be detected automatically, and usescheme
,zerocolor
andmaskcolor
keywords if available. Can be aVector/Matrix
for multiple grids, matching thelayout
array.
(See DynamicGrids.jl docs for more details)
An ImageConfig
object can be also passed to the imageconfig
keyword, and other keywords will be ignored.