My original plan was to create a simulation of ink spreading in water (spoiler: I didn’t succeed). I figured that I was looking at diffusion, so I used the following model: start with 50 points at one position (a Diffusing Drop). Each of these points now execute a random walk. What would it look like? You can see the results below and play with the parameters.
When the diffusion speed
(the size of the step each particle takes) is small, the result looks like diffusion of ink on paper (not water, unfortunately). When the speed is around 5, after a few seconds you get something similar to space clouds. When it is 10, you get colorful dust clouds. For the ink spreading in water effect I need to also simulate micro-currents etc. haven’t gotten there yet :)
You can play with the speed, the number of drops, and the colors below. Each Diffusing Drop is color 1 with a probability of 0.5 and color 2 otherwise. The p5.js code for the sketch is available in the site repository. You can also embed it in your site or web-screensaver by using this link with the following optional parameters:
diffusionSpeed
the speed of the diffusionnumDrops
the number of diffusing dropsrunTime
the amount of time (in ms) that the sketch will run before resetting.
Here is an example withdiffusionSpeed
= 1,numDrops
= 10 andrunTime
= 5 seconds.
All my sketches are free for commercial and personal use with attribution (BSD 3-clause license).