@urban-toolkit/autk-grammar 4.0.0 → 4.1.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
@@ -12,7 +12,7 @@ A declarative grammar for urban visual analytics, running on [Autark](https://au
12
12
  npm install @urban-toolkit/autk-grammar
13
13
  ```
14
14
 
15
- It runs on Autark 4: `@urban-toolkit/autk-core`, `autk-db`, `autk-map`, `autk-plot` and `autk-compute` 4.x, installed with it.
15
+ It runs on Autark 4.1: `@urban-toolkit/autk-core`, `autk-db`, `autk-map`, `autk-plot` and `autk-compute` 4.1 or a later 4.x, installed with it.
16
16
 
17
17
  ## Usage
18
18
 
@@ -29,6 +29,18 @@ const grammar = new AutkGrammar({ map: 'map', plot: 'plot' }); // ids of the map
29
29
  await grammar.run(spec);
30
30
  ```
31
31
 
32
+ ## Maps
33
+
34
+ Each map draws on demand: one frame once its layers are loaded, then one each time it changes. `grammar.maps` holds the `AutkMap` of each `map` entry of the last run, in order. Between frames a map canvas can read back empty, so to read a map's pixels (for example with `canvas.toDataURL()`), call its `requestRender()` and read in a `requestAnimationFrame` callback registered after that call:
35
+
36
+ ```ts
37
+ const map = grammar.maps[0];
38
+ map.requestRender();
39
+ requestAnimationFrame(() => {
40
+ const png = map.canvas.toDataURL('image/png');
41
+ });
42
+ ```
43
+
32
44
  ## JSON Schema
33
45
 
34
46
  The package ships the grammar's JSON Schema (draft-07) as `@urban-toolkit/autk-grammar/build/autk-grammar-schema.json`, with `$id` `https://autarkjs.org/schema/autk-grammar/v1.json`. Validate a spec with any draft-07 validator: