Simon Danisch / Dec 18 2018

Turing Patterns

pkg"add https://github.com/yurivish/TuringPatterns.jl.git ImageMagick WebSockets WebIO Interact Colors ImageShow"
ENV["WEBIO_BUNDLE_URL"] = "https://rawgit.com/JuliaGizmos/WebIO.jl/master/packages/generic-http-provider/dist/generic-http.js"
using WebSockets, WebIO, Interact, Colors, ImageShow, TuringPatterns
sz = (650, 650);
# Create an empty image that we update later
obs = Observable(zeros(sz...))
img = Observables.async_latest(map(x-> Gray.((x .+ 1f0) ./ 2f0), obs))
patterns = [
    SimplePattern(Params(2,   4,   0.01), sz),
    SimplePattern(Params(5,   10,  0.02), sz),
    SimplePattern(Params(10,  20,  0.03), sz),
    SimplePattern(Params(20,  40,  0.04), sz),
    SimplePattern(Params(50,  100, 0.05), sz),
]
sim = Sim(
  rand(sz...),    # initial conditions
  patterns,    # patterns
  Clamp(),
  BoxBlur(sz), # blur
);
for i = 1:100
 	TuringPatterns.step!(sim)
  # somehow display takes really long, so just display each 5th step
  (i%7 == 0) && (obs[] = sim.fluid) 
  yield()
end;
obs[] = sim.fluid;
using CairoMakie, AbstractPlotting
heatmap(sim.fluid, show_axis = false)