diff --git a/src/electron.jl b/src/electron.jl index 3d73896..e0471a7 100644 --- a/src/electron.jl +++ b/src/electron.jl @@ -72,7 +72,7 @@ DG.delay(o::ElectronOutput, x) = DG.delay(interface(o), x) DG.minval(o::ElectronOutput) = DG.minval(interface(o)) DG.maxval(o::ElectronOutput) = DG.maxval(interface(o)) -DG.processor(o::ElectronOutput) = DG.processor(interface(o)) +DG.imagegen(o::ElectronOutput) = DG.imagegen(interface(o)) DG.storeframe!(o::ElectronOutput, data::DG.AbstractSimData) = DG.storeframe!(interface(o), data) diff --git a/src/interact.jl b/src/interact.jl index b217a20..66438e2 100644 --- a/src/interact.jl +++ b/src/interact.jl @@ -6,25 +6,27 @@ abstract type AbstractInteractOutput{T,F} <: ImageOutput{T,F} end """ - InteractOutput(init; ruleset, fps=25.0, store=false, - processor=ColorProcessor(), minval=nothing, maxval=nothing, - extrainit=Dict()) + InteractOutput <: DynamicGrids.ImageOutput + + InteractOutput(init; ruleset, kw...) An `Output` for Atom/Juno and Jupyter notebooks, and the back-end for [`ElectronOutput`](@ref) and [`ServerOutput`](@ref). - ### Arguments: -- `init`: initialisation Array or NamedTuple of arrays. -### Keyword Arguments: -- `ruleset`: the ruleset to run in the interface simulations. -- `tspan`: `AbstractRange` timespan for the simulation +- `init`: initialisation `Array` or `NamedTuple` of arrays. + +### Keywords + +- `ruleset::Ruleset`: the ruleset to run in the interface simulations. +- `tspan::AbstractRange`: timespan for the simulation - `fps::Real`: frames per second to display the simulation -- `store::Bool`: whether ot store the simulation frames for later use -- `processor::GridProcessor -- `minval::Number`: minimum value to display in the simulation -- `maxval::Number`: maximum value to display in the simulation +- `store::Bool`: whether ot store the simulation frames for later use. +- `imagegen::ImageGenerator`: Converts the grid to an image, auto-detected by default. +- `minval::Number`: minimum value to display from a grid, `0` by default. +- `maxval::Number`: maximum value to display from a grid, `1` by default. + """ mutable struct InteractOutput{T,F<:AbstractVector{T},E,GC,IC,RS<:Ruleset,Pa,IM,TI} <: AbstractInteractOutput{T,F} frames::F diff --git a/test/runtests.jl b/test/runtests.jl index d215476..87008b2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -23,8 +23,8 @@ test5 = [0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0] -processor = ColorProcessor( - scheme=ColorSchemes.leonardo, zerocolor=nothing, maskcolor=nothing, textconfig=nothing, +imagegen = Image( + scheme=ColorSchemes.leonardo, zerocolor=nothing, maskcolor=nothing, ) @testset "InteractOutput" begin @@ -39,7 +39,9 @@ processor = ColorProcessor( l0 l0 l0 l0 l0 l0] ruleset = Ruleset(Life(); boundary=Wrap()) - output = InteractOutput(init; tspan=1:2, ruleset=ruleset, store=true, processor=processor); + output = InteractOutput(init; + tspan=1:2, ruleset=ruleset, store=true, text=nothing, imagegen=imagegen + ) sim!(output, ruleset) sleep(10) resume!(output, ruleset; tstop=5) @@ -54,7 +56,9 @@ processor = ColorProcessor( end @testset "output works with store=false" begin - output = InteractOutput(init; ruleset=ruleset, tspan=1:3, store=false, processor=processor); + output = InteractOutput(init; + ruleset=ruleset, tspan=1:3, store=false, text=nothing, imagegen=imagegen + ) sim!(output, ruleset) output.graphicconfig.stoppedframe DynamicGrids.stoppedframe(output) @@ -69,7 +73,9 @@ end if !Sys.islinux() # No graphic head loaded in CI: TODO add this @testset "ElectronOutput" begin ruleset = Ruleset(Life(); boundary=Wrap()) - output = ElectronOutput(init; ruleset=ruleset, tspan=1:3, store=true, processor=processor) + output = ElectronOutput(init; + ruleset=ruleset, tspan=1:300, store=true, text=nothing, imagegen=imagegen + ) DynamicGrids.setrunning!(output, false) sim!(output.interface, ruleset) sleep(10) @@ -84,6 +90,6 @@ end @testset "ServerOutput" begin ruleset = Ruleset(Life(); boundary=Wrap()) - ServerOutput(init; ruleset=ruleset, port=8080, processor=processor) + ServerOutput(init; ruleset=ruleset, port=8080, imagegen=imagegen) # TODO: test the server somehow end