All Projects → jasonwebb → 2d-diffusion-limited-aggregation-experiments

jasonwebb / 2d-diffusion-limited-aggregation-experiments

Licence: other
Visual experiments exploring diffusion-limited aggregation (DLA) as a 2D morphogenesis tool.

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to 2d-diffusion-limited-aggregation-experiments

2d Differential Growth Experiments
Visual experiments exploring differential growth as a 2D morphogenesis tool.
Stars: ✭ 140 (+241.46%)
Mutual labels:  creative-coding, generative-art, 2d
2d Space Colonization Experiments
Visual experiments exploring space colonization as a 2D morphogenesis tool.
Stars: ✭ 91 (+121.95%)
Mutual labels:  creative-coding, generative-art, 2d
Watercolor Canvas
Creating watercolor-style canvas art
Stars: ✭ 84 (+104.88%)
Mutual labels:  creative-coding, generative-art
Ink
Creative coding in Go
Stars: ✭ 115 (+180.49%)
Mutual labels:  creative-coding, generative-art
Urpflanze
A library for developers who want to approach to creative coding, artists who want to approach coding and for those who find it fun to play with math.
Stars: ✭ 118 (+187.8%)
Mutual labels:  creative-coding, generative-art
Awesome Creative Coding
Creative Coding: Generative Art, Data visualization, Interaction Design, Resources.
Stars: ✭ 8,696 (+21109.76%)
Mutual labels:  creative-coding, generative-art
001
draw_code.001 — ThreeJS, WebGL & GLSL
Stars: ✭ 48 (+17.07%)
Mutual labels:  creative-coding, generative-art
Glisp
A Lisp-based Design Tool Bridging Graphic Design and Computational Arts
Stars: ✭ 519 (+1165.85%)
Mutual labels:  creative-coding, generative-art
generative-art
Generative art experiments
Stars: ✭ 113 (+175.61%)
Mutual labels:  creative-coding, generative-art
BeatDrop
BeatDrop Music Visualizer
Stars: ✭ 54 (+31.71%)
Mutual labels:  creative-coding, generative-art
JRubyArt
JRubyArt a ruby implementation of processing
Stars: ✭ 87 (+112.2%)
Mutual labels:  creative-coding, generative-art
Worlds2
Building Virtual Reality Worlds using Three.js
Stars: ✭ 34 (-17.07%)
Mutual labels:  creative-coding, generative-art
Curv
a language for making art using mathematics
Stars: ✭ 853 (+1980.49%)
Mutual labels:  creative-coding, generative-art
Sketches
a starting point for sketches
Stars: ✭ 66 (+60.98%)
Mutual labels:  creative-coding, generative-art
Dungeontemplatelibrary
🌏: Dungeon free resources (terrain & roguelike generation)
Stars: ✭ 595 (+1351.22%)
Mutual labels:  creative-coding, generative-art
generative-art-Processing
Processingによるアート作品をまとめたリポジトリです.一部の作品はopenFrameworksで書かれています.This is a repository for art portfolio of Processing art. Some of arts are written in openFrameworks, one of the C++ libraries.
Stars: ✭ 31 (-24.39%)
Mutual labels:  creative-coding, generative-art
Q5xjs
A small and fast alternative (experimental) implementation of p5.js
Stars: ✭ 334 (+714.63%)
Mutual labels:  creative-coding, 2d
Pts
A library for visualization and creative-coding
Stars: ✭ 4,628 (+11187.8%)
Mutual labels:  creative-coding, generative-art
react-text-fun
React meets Blotter.js
Stars: ✭ 51 (+24.39%)
Mutual labels:  creative-coding, generative-art
worlds
Building Virtual Reality Worlds using Three.js
Stars: ✭ 23 (-43.9%)
Mutual labels:  creative-coding, generative-art

Read my Medium article to learn more about diffusion-limited aggregation and this project.

Additional media is available on my portfolio

This repo contains a series of visual experiments built with JavaScript that explore the topic of diffusion-limited aggregation (DLA) as a method for generating interesting 2D forms.

I am particularly interested in the application of such techniques in the context of digital fabrication, so these experiments will be more focused on schematic representations (colorless, vector-based, SVG/STL exports) over purely visual effects.

About diffusion-limited aggregation

Diffusion-limited aggregation (DLA) is a process in which randomly-moving particles diffuse through a medium and clump together (aggregate) over time to form long, fractal, branch-like chains (sometimes called Brownian trees). It closely models various interesting phenomena seen in nature at different scales and in different mediums.

A classic example is that of the formation of copper sulfate crystals in the presence of an electrodeposition cell. When electricity is applied, individual copper atoms are stripped from the system's anode and randomly float (diffuse) through the liquid medium until they come in contact with other copper atoms that have accumulated on the system's cathode where they form a strong molecular bond and aggregate over time.

Another example can be seen in the rather more violent phenomena of Lichtenberg figures, wherein an electrical discharge of very high voltage travels through an insulator like wood, burning a curious fractal branching structure in it's wake. In this example, it would seem that the electrical discharge itself diffuses through the wood, limited by the insulating nature of the wood, forming an "aggregate" of burnt wood as it progresses.

A note on lattices and parameterization

In classical implementations this algorithm acts upon a regular 2D grid of pixels wherein each "particle" can have up to 8 neighbors. Though simplistic, this so-called "on-lattice" approach can run at blistering speeds because no expensive distance calculations, spatial indexing, or collision detection is required - just array lookups.

However, this approach results in an inherently low fidelity raster image that has a pretty characteristic aesthetic style and limited usefulness in modern digital fabrication workflows. In the world of digital fabrication vector-based graphics are preferred because they can be easily transformed into machine toolpaths and manipulated in interesting ways in CAD software.

To achieve vector-based results from the DLA process one must move away from pixels and towards particles, which also affords one the ability for more parameterization that can be fun to explore creatively. For example, one could vary the size, shape, and movement behaviors of these particles to achieve interesting effects.

Keyboard commands

Key Result
w Toggle visibility of walkers
c Toggle visibility of clustered particles
s Toggle visibility of custom SVG shapes
r Restart simulation
f Toggle frame
l Toggle line rendering effect
e Export and initiate download of current drawing as SVG file
t Toggle visibility of helpful text
Space Pause/unpause simulation

Parameters

Parameter Value Default Description
CircleDiameter Number 5 Default size of walkers, if none is provided through local Settings.
InitialClusterType Point, Ring, Random, or Wall Point Default initial cluster pattern, if none is provided through local Settings.
ShowClusters Boolean true Visibility of clustered particles on load.
ShowWalkers Boolean true Visibility of walkers on load.
ShowShapes Boolean true Visibility of custom SVG shapes on load.
MaxWalkers Number 20000 Maximum number of walkers - lower numbers mean better performance, but fewer hits.
WalkerSource Edges, Circle, Random, Random-Circle, or Center Center Where new walkers are spawned.
ReplenishWalkers Boolean false Add new walkers whenever they become stuck to clusters.
BiasTowards Top, Bottom, Left, Right, Edges, Center, Equator, or Meridian Center Direction to move all walkers each iteration.
BiasForce Number 1 Magnitude of force to move walkers towards their bias direction.
UseFrame Boolean true Constrain sketch to a box centered on the screen.
FrameSize Number or [width, height] 900 Size of frame.
CaptureLines Boolean true Enable building of an internal buffer of line segments between all connected particles. Can be disabled if it impacts performance at large scales.
RenderMode Shapes or Lines Shapes Method of drawing particles. Can draw the shapes as they exist (Shapes), or only draw lines between connected particles (Lines).
UseColors Boolean false Enable the use of colors defined by objects below.
UseStroke Boolean false Draws all circles/polygons with a 1px stroke matching the background color.
BackgroundColor Object with h, s, b properties Color of canvas background in HSB format.
WalkerColor Object with h, s, b properties Color of walkers in HSB format.
ClusterColor Object with h, s, b properties Color of clustered particles in HSB format.
ShapeColor Object with h, s, b properties Color of custom SVG shapes in HSB format.
LineColor Object with h, s, b properties Color of lines when using Lines for RenderMode.
FrameColor Object with h, s, b properties Color of frame, if enabled with UseFrame.

Packages used

  • p5.js for canvas drawing and miscellaneous helper functions (like lerp and map).
  • Webpack for modern JS (ES6) syntax, code modularization, bundling, and serving locally.
  • collisions for robust, lightweight collision detection without the use of a full physics package.
  • svg-pathdata for parsing path information from SVG files in order to create custom shapes.
  • svg-points for generating the d attribute of SVG <path> elements for export feature.
  • file-saver for initiating a download of exported SVG fles to the user's machine.

Running locally

  1. Run npm install in both the root (/) and ./core folders.
  2. Run npm run serve to start a local development server and launch it in a browser.

To statically build the code in this repo, run npm run build in the root folder.

Going further

The code in this repo can be improved or optimized in a few ways to achieve faster performance and larger scales. Here are some ideas that come to mind:

  1. Rather than using brute-force movement and collision detection (which limit overall scale + speed), implement an algorithm like Michael Fogleman's dlaf. This may mean that one would have to do away with variable particle shapes and sizes, but I imagine variable sizes could be accommodated with some tweaking.
  2. Port code over to a more performant language / library like openFrameworks or Cinder.

References

Samples

Basic DLA Directional bias Different sizes Different shapes SVG input Basic DLA with color Line rendering effect

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].