reaction-diffusion/grayscott.bqn

32 lines
1 KiB
BQN
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

PBM,PPM•Import"../bqn-graphics/pnm.bqn"
Inferno,Magma,Viridis•Import"../bqn-graphics/colormaps.bqn"
# Parameters
dtdadbfk1.0,0.16,0.08,0.060,0.062
n500 # image size
m150 # seed size at the center of the image
# Discrete Laplacian
Lapl(+´1¯1(˘)¨<)-4×
# Gray-Scott update
UpdateA{𝕨+dt×(da×Lapl 𝕨)+(-𝕨×𝕩2)+f×1-𝕨}
UpdateB{𝕩+dt×(db×Lapl 𝕩)+(𝕨×𝕩2)-𝕩×k+f}
Update(UpdateAUpdateB)´
# Initialization
ann1
SquareMask{𝕩𝕩(-𝕨𝕨+𝕩÷2)(2×𝕨𝕨)1}
CircleMask{(𝕨×𝕨)()()+(2)˜𝕩÷2}
mask(nn•rand.Range 2)×m CircleMask n
bmask0.05×nn•rand.Range 0
# Run
Step{stepsize 𝕊 iab:
•Show i×stepsize
apbpUpdatestepsize ab
("out/step"(¯5•Fmt¨5-i)".pnm")•file.Chars (PPM 255×>Viridis¨1-a)@+10
(i+1)apbp
}
50 Step•_while_(600>) 0ab
•Out""