@wonderyard/vivarium 1.5.0 → 2.0.0

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 CHANGED
@@ -73,7 +73,7 @@ const life = vi.create();
73
73
  const canvas = document.createElement(canvas);
74
74
  document.body.appendChild(canvas);
75
75
 
76
- // Set the canvas size. This will be the automaton size as well.
76
+ // Set the canvas size (must be a power of 2). This will be the automaton size as well.
77
77
  const size = 256;
78
78
  canvas.width = size;
79
79
  canvas.height = size;
@@ -9,6 +9,7 @@ export type Kind = {
9
9
  export type Color = string;
10
10
  export type Automaton = {
11
11
  neighborhood: Neighborhood;
12
+ wrapping: boolean;
12
13
  elements: Element[];
13
14
  kinds: Kind[];
14
15
  rules: Rule[];
@@ -1,7 +1,7 @@
1
1
  import { BaseBlueprint as n } from "./base-blueprint.js";
2
- import { R as p } from "../rule-blueprint-CIEvYOmb.js";
2
+ import { R as p } from "../rule-blueprint-C9qa6iP-.js";
3
3
  import { toRefIdOrPoint as d } from "./utils.js";
4
- import { A as u } from "../constants-BMg7uvpO.js";
4
+ import { A as u } from "../constants-BT-9-x_4.js";
5
5
  class o extends n {
6
6
  constructor(e, t) {
7
7
  super(), this.automaton = e, this.id = t.id, this.name = t.name, this.type = t.type;
@@ -1,7 +1,7 @@
1
- import { R as o, a as l } from "../rule-blueprint-CIEvYOmb.js";
1
+ import { R as o, a as l } from "../rule-blueprint-C9qa6iP-.js";
2
2
  import "./base-blueprint.js";
3
3
  import "./utils.js";
4
- import "../constants-BMg7uvpO.js";
4
+ import "../constants-BT-9-x_4.js";
5
5
  export {
6
6
  o as RuleBlueprint,
7
7
  l as RuleBlueprintWithAccept
@@ -1,4 +1,4 @@
1
- import { n as t } from "../constants-BMg7uvpO.js";
1
+ import { n as t } from "../constants-BT-9-x_4.js";
2
2
  const s = (o) => typeof o == "string" ? t[o] : o.id;
3
3
  export {
4
4
  s as toRefIdOrPoint
@@ -27,7 +27,9 @@ export declare class VivariumBlueprint<N extends Neighborhood = "square"> extend
27
27
  * Includes {@link Helpers.not | not}, {@link Helpers.between | between}, {@link Helpers.even | even}, and {@link Helpers.odd | odd}.
28
28
  */
29
29
  helpers: Helpers;
30
- constructor(neighborhoodName?: N | undefined);
30
+ constructor(neighborhoodName?: N | undefined, options?: {
31
+ wrapping?: boolean;
32
+ });
31
33
  /**
32
34
  * Defines a new element in the vivarium.
33
35
  *
@@ -1,12 +1,13 @@
1
- import { n as o } from "../rule-blueprint-CIEvYOmb.js";
1
+ import { n as o } from "../rule-blueprint-C9qa6iP-.js";
2
2
  import { BaseBlueprint as a } from "./base-blueprint.js";
3
3
  import { Helpers as h } from "./helpers.js";
4
4
  import { ElementBlueprint as m, KindBlueprint as u } from "./ref-blueprint.js";
5
- import { C as d, S as p } from "../constants-BMg7uvpO.js";
6
- class b extends a {
7
- constructor(t) {
8
- super(), this.neighborhoodName = t, this.helpers = new h(this.neighborhoodName), this.neighbor = this.neighborhoodName === "cross" ? d : p, this.automaton = {
5
+ import { C as p, S as d } from "../constants-BT-9-x_4.js";
6
+ class C extends a {
7
+ constructor(t, e) {
8
+ super(), this.neighborhoodName = t, this.helpers = new h(this.neighborhoodName), this.neighbor = this.neighborhoodName === "cross" ? p : d, this.automaton = {
9
9
  neighborhood: t ?? "square",
10
+ wrapping: e?.wrapping ?? !1,
10
11
  elements: [],
11
12
  kinds: [],
12
13
  rules: []
@@ -75,5 +76,5 @@ class b extends a {
75
76
  }
76
77
  }
77
78
  export {
78
- b as VivariumBlueprint
79
+ C as VivariumBlueprint
79
80
  };
@@ -62,3 +62,4 @@ export declare const GpuCondition: d.WgslStruct<{
62
62
  chance: d.F32;
63
63
  }>;
64
64
  export declare const WORKGROUP_SIZE: [number, number];
65
+ export declare const MIN_GRID_SIZE: number;
@@ -1,14 +1,15 @@
1
- import { A as o, C as e, b as p, G as c, a as n, O as t, S as r, T as u, c3 as G, c as i, n as O } from "../constants-BMg7uvpO.js";
1
+ import { A as o, C as e, b as c, G as p, a as n, c4 as t, O as G, S as r, T as u, c3 as i, c as I, n as O } from "../constants-BT-9-x_4.js";
2
2
  export {
3
3
  o as Accept,
4
4
  e as Cross,
5
- p as GpuCondition,
6
- c as GpuElement,
5
+ c as GpuCondition,
6
+ p as GpuElement,
7
7
  n as GpuRule,
8
- t as Opcode,
8
+ t as MIN_GRID_SIZE,
9
+ G as Opcode,
9
10
  r as Square,
10
11
  u as To,
11
- G as WORKGROUP_SIZE,
12
- i as acceptMap,
12
+ i as WORKGROUP_SIZE,
13
+ I as acceptMap,
13
14
  O as neighborhoodPoints
14
15
  };
@@ -295,11 +295,11 @@ const f = (e) => {
295
295
  const t = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
296
296
  e = e.replace(
297
297
  t,
298
- (l, a, c, n) => a + a + c + c + n + n
298
+ (l, a, n, c) => a + a + n + n + c + c
299
299
  );
300
300
  const r = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);
301
301
  if (!r)
302
- throw new Error("Bad color");
302
+ throw new Error(`Bad color: ${e}`);
303
303
  const s = parseInt(r[1], 16), u = parseInt(r[2], 16);
304
304
  return 4278190080 | parseInt(r[3], 16) << 16 | u << 8 | s;
305
305
  };