gum-jsx 1.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 ADDED
@@ -0,0 +1,78 @@
1
+ <div align="center">
2
+ <img src="image/logo.svg" alt="logo" width="500" />
3
+ <br/>
4
+ </div>
5
+
6
+ <div align="center">
7
+ <img src="image/nexus.svg" alt="nexus" width="250" />
8
+ <br/><br/>
9
+ </div>
10
+
11
+ A language for creating visualizations using a React-like JSX dialect that evaluates to SVG. Designed for general graphics, plots, graphs, and network diagrams.
12
+
13
+ Head to **[compendiumlabs.ai/gum](https://compendiumlabs.ai/gum)** for a live demo and documentation. For Python bindings, see **[gum.py](https://github.com/CompendiumLabs/gum.py)**.
14
+
15
+ # Installation
16
+
17
+ ```bash
18
+ npm install gum
19
+ ```
20
+
21
+ # Usage
22
+
23
+ Write some `gum.jsx` code:
24
+
25
+ ```jsx
26
+ <Plot xlim={[0, 2*pi]} ylim={[-1, 1]} grid margin={0.2} aspect={2}>
27
+ <SymLine fy={sin} stroke={blue} stroke-width={2} />
28
+ </Plot>
29
+ ```
30
+
31
+ Then evaluate it to SVG:
32
+
33
+ ```javascript
34
+ import { evaluateGum } from 'gum/eval'
35
+ const elem = evaluateGum(jsx)
36
+ const svg = elem.svg()
37
+ ```
38
+
39
+ You can also use JavaScript directly:
40
+
41
+ ```javascript
42
+ import { Svg, Box, Text, Circle, Plot, SymLine, pi, sin } from 'gum'
43
+ const elem = new Plot({
44
+ children: new SymLine({ fy: sin, stroke: blue, stroke_width: 2 }),
45
+ xlim: [0, 2*pi], ylim: [-1, 1], grid: true, margin: 0.2, aspect: 2,
46
+ })
47
+ const svg = elem.svg()
48
+ ```
49
+
50
+ # CLI
51
+
52
+ You can use the `gum` command to convert `gum.jsx` into SVG text or PNG data. At that point you can either pipe them to a file or even display them directly in the terminal using `chafa`! For the latter you need a terminal that supports images, such as `ghostty`. There are a bunch of code examples in `docs/code/` and `docs/gallery/` to try out.
53
+
54
+ Generate an SVG from a `gum.jsx` file:
55
+
56
+ ```bash
57
+ cat input.jsx | npx gum > output.svg
58
+ ```
59
+
60
+ Generate a PNG from a `gum.jsx` file:
61
+
62
+ ```bash
63
+ cat input.jsx | npx gum -f png > output.png
64
+ ```
65
+
66
+ Display a `gum.jsx` file with `chafa`:
67
+ ```bash
68
+ cat input.jsx | npx gum | chafa -s 75 -
69
+ ```
70
+
71
+ CLI options:
72
+
73
+ | Option | Description | Default |
74
+ |--------|-------------|---------|
75
+ | `-s, --size <size>` | Image size in pixels | 500 |
76
+ | `-f, --format <format>` | Output format: `svg` or `png` | svg |
77
+ | `-t, --theme <theme>` | Theme: `light` or `dark` | light |
78
+ | `-b, --background <color>` | Background color | null |