https://github.com/ubavic/chaos-game
Interactive demonstration of the Chaos game
https://github.com/ubavic/chaos-game
complex-dynamics fractals iterated-function-system
Last synced: about 1 year ago
JSON representation
Interactive demonstration of the Chaos game
- Host: GitHub
- URL: https://github.com/ubavic/chaos-game
- Owner: ubavic
- License: mit
- Created: 2023-03-17T23:22:22.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-26T17:33:12.000Z (about 3 years ago)
- Last Synced: 2025-03-14T21:46:29.640Z (over 1 year ago)
- Topics: complex-dynamics, fractals, iterated-function-system
- Language: JavaScript
- Homepage: https://ubavic.rs/chaos_game
- Size: 122 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Chaos game
Interactive demonstration of the [Chaos game](https://en.wikipedia.org/wiki/Chaos_game), written in pure JavaScript. This program renders images to a canvas element, while commands are implemented via HTML form elements and SVG.
In this demonstration, all vertices and parameters are treated as complex numbers.
The orbit of the point $P_0$ is generated iteratively by the formula
$$P_{i+1} = \lambda (P_i + V)$$
where $V$ is a randomly chosen vertex of the polygon, and $\lambda$ is fixed parameter (in the "original" Chaos game, $\lambda = \frac{1}{2}$).

## Hacking and Contributing
Even if the code contains a few hundred lines, the main drawing logic is concentrated in a few lines of the `draw` function.
All other functions are used for UI.
Some ideas for future development
+ Better control of 'clearing' between redraws
+ More control of the number of iterations per frame. Automatic selection based on the time required to render a frame
+ Advanced rules: disallowing consequent selection of same vertex, forbidden domains, etc...
+ Switching to WebGL renderer/WASM core if that brings more performance
Contributions and new ideas are more than welcome.