@wonderyard/vivarium 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Vivarium
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="docs/banner.png" />
|
|
5
|
+
</p>
|
|
4
6
|
|
|
5
7
|
## Introduction
|
|
6
8
|
|
|
@@ -8,13 +10,13 @@ Vivarium is a TypeScript library that aims to provide a simple yet expressive wa
|
|
|
8
10
|
|
|
9
11
|
Vivarium exposes a minimal API that attempts to express complex rules and conditions in a way that resembles natural language. Concepts and technical terms from the cellular automata theory are almost transparent to the user. This way the cognitive effort of translating ideas into code is reduced. By lowering this barrier we enable fast prototyping during the creative coding process, especially for users who are approaching the cellular automata world for the first time.
|
|
10
12
|
|
|
11
|
-
Read the
|
|
13
|
+
Read the [docs](https://vivarium.orangenote.dev) to get started, or continue reading for a quick overview and [demo](https://vivarium-demo.netlify.app/).
|
|
12
14
|
|
|
13
15
|
## Overview
|
|
14
16
|
|
|
15
17
|
### Install
|
|
16
18
|
|
|
17
|
-
Install Vivarium as a dependency. No other
|
|
19
|
+
Install Vivarium as a dependency. No other dependencies required.
|
|
18
20
|
|
|
19
21
|
```bash
|
|
20
22
|
npm i @wonderyard/vivarium
|
|
@@ -32,37 +34,37 @@ yarn add @wonderyard/vivarium
|
|
|
32
34
|
|
|
33
35
|
Import it once and use it anywhere.
|
|
34
36
|
|
|
35
|
-
```
|
|
37
|
+
```typescript
|
|
36
38
|
import { vivarium, setup } from "@wonderyard/vivarium";
|
|
37
39
|
```
|
|
38
40
|
|
|
39
41
|
### Create
|
|
40
42
|
|
|
41
|
-
To give you an idea of what the API can offer and how intuitive it can be to reason about rules and conditions, we recreated the most popular cellular automaton: [Conway's Game of Life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life). Now featuring (with a little bit of imagination)
|
|
43
|
+
To give you an idea of what the API can offer and how intuitive it can be to reason about rules and conditions, we recreated the most popular cellular automaton: [Conway's Game of Life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life). Now featuring (with a little bit of imagination) green aliens 👽
|
|
42
44
|
|
|
43
|
-
> We suggest you to read about Game of Life and how it works before continuing reading. If you don't understand clearly what the following code is representing, it's okay! Visit the
|
|
45
|
+
> We suggest you to read about Game of Life and how it works before continuing reading. If you don't understand clearly what the following code is representing, it's okay! Visit the [docs](https://vivarium.orangenote.dev) for a gentler introduction to cellular automata and what vivarium is meant for.
|
|
44
46
|
|
|
45
|
-
```
|
|
47
|
+
```typescript
|
|
46
48
|
const vi = vivarium();
|
|
47
49
|
|
|
48
|
-
const space = vi.element("space", "
|
|
49
|
-
const
|
|
50
|
+
const space = vi.element("space", "blue");
|
|
51
|
+
const alien = vi.element("alien", "green");
|
|
50
52
|
|
|
51
|
-
//
|
|
52
|
-
space.to(
|
|
53
|
+
// An alien is born if there's a family of 3 in the area.
|
|
54
|
+
space.to(alien).count(alien, 3);
|
|
53
55
|
|
|
54
|
-
// The
|
|
55
|
-
|
|
56
|
+
// The alien stays if the area is neither too empty nor too crowded...
|
|
57
|
+
alien.to(alien).count(alien, 2, 3);
|
|
56
58
|
|
|
57
|
-
// ...otherwise the
|
|
58
|
-
|
|
59
|
+
// ...otherwise the alien will leave the area forever.
|
|
60
|
+
alien.to(space);
|
|
59
61
|
|
|
60
62
|
const life = vi.create();
|
|
61
63
|
```
|
|
62
64
|
|
|
63
65
|
### Run
|
|
64
66
|
|
|
65
|
-
```
|
|
67
|
+
```typescript
|
|
66
68
|
// Create a new canvas (or you could use an existing one)
|
|
67
69
|
const canvas = document.createElement(canvas);
|
|
68
70
|
document.body.appendChild(canvas);
|
|
@@ -83,7 +85,7 @@ const loop = async () => {
|
|
|
83
85
|
requestAnimationFrame(loop);
|
|
84
86
|
```
|
|
85
87
|
|
|
86
|
-
|
|
88
|
+
[See the live demo here](https://vivarium-demo.netlify.app/)
|
|
87
89
|
|
|
88
90
|
## Browser compatibility
|
|
89
91
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wonderyard/vivarium",
|
|
3
3
|
"description": "Modern, intuitive, WebGPU-powered toolkit for creating your own cellular automata.",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.7",
|
|
5
5
|
"repository": "https://github.com/WonderYard/vivarium",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "OrangeNote",
|