gum-jsx 1.3.1 → 1.5.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/LICENSE +7 -0
- package/README.md +14 -8
- package/docs/code/Arc.jsx +5 -0
- package/docs/code/{arrays.jsx → Arrays.jsx} +1 -1
- package/docs/code/Arrow.jsx +8 -0
- package/docs/code/{barplot.jsx → BarPlot.jsx} +3 -3
- package/docs/code/Bracket.jsx +7 -0
- package/docs/code/{colors.jsx → Colors.jsx} +2 -2
- package/docs/code/{edge.jsx → Edge.jsx} +1 -1
- package/docs/code/{element.jsx → Element.jsx} +1 -1
- package/docs/code/Ellipse.jsx +5 -0
- package/docs/code/Fill.jsx +6 -0
- package/docs/code/Frac.jsx +13 -0
- package/docs/code/{graph.jsx → Graph.jsx} +3 -3
- package/docs/code/{grid.jsx → Grid.jsx} +2 -2
- package/docs/code/Group.jsx +5 -0
- package/docs/code/Images.jsx +6 -0
- package/docs/code/{latex.jsx → Latex.jsx} +6 -2
- package/docs/code/{line.jsx → Line.jsx} +4 -4
- package/docs/code/Math.jsx +14 -0
- package/docs/code/MathText.jsx +10 -0
- package/docs/code/{network.jsx → Network.jsx} +3 -3
- package/docs/code/{node.jsx → Node.jsx} +1 -1
- package/docs/code/{points.jsx → Points.jsx} +4 -5
- package/docs/code/{rect.jsx → Rect.jsx} +1 -1
- package/docs/code/{shape.jsx → Shape.jsx} +4 -4
- package/docs/code/{spline.jsx → Spline.jsx} +3 -3
- package/docs/code/{stack.jsx → Stack.jsx} +3 -3
- package/docs/code/SupSub.jsx +8 -0
- package/docs/code/SymField.jsx +4 -0
- package/docs/code/{sympoints.jsx → SymPoints.jsx} +2 -2
- package/docs/code/{symspline.jsx → SymSpline.jsx} +1 -1
- package/docs/code/Tables.jsx +6 -0
- package/docs/code/{text.jsx → Text.jsx} +1 -1
- package/docs/code/{unitline.jsx → UnitLine.jsx} +1 -1
- package/docs/data/data.csv +7 -0
- package/docs/data/image.png +0 -0
- package/docs/meta.json +44 -34
- package/docs/text/Arc.md +11 -0
- package/docs/text/{arrays.md → Arrays.md} +0 -2
- package/docs/text/Arrow.md +21 -0
- package/docs/text/Axis.md +29 -0
- package/docs/text/{barplot.md → BarPlot.md} +2 -2
- package/docs/text/{box.md → Box.md} +1 -0
- package/docs/text/Bracket.md +12 -0
- package/docs/text/{colors.md → Colors.md} +1 -1
- package/docs/text/Edge.md +16 -0
- package/docs/text/{element.md → Element.md} +5 -5
- package/docs/text/Fill.md +16 -0
- package/docs/text/Frac.md +11 -0
- package/docs/text/Graph.md +12 -0
- package/docs/text/Group.md +13 -0
- package/docs/text/{gum.md → Gum.md} +1 -1
- package/docs/text/Images.md +9 -0
- package/docs/text/Latex.md +9 -0
- package/docs/text/{line.md → Line.md} +1 -1
- package/docs/text/{math.md → Math.md} +4 -0
- package/docs/text/MathText.md +13 -0
- package/docs/text/{network.md → Network.md} +2 -2
- package/docs/text/{node.md → Node.md} +1 -1
- package/docs/text/{plot.md → Plot.md} +1 -1
- package/docs/text/Points.md +13 -0
- package/docs/text/{shape.md → Shape.md} +2 -1
- package/docs/text/{spline.md → Spline.md} +4 -2
- package/docs/text/{stack.md → Stack.md} +4 -3
- package/docs/text/SupSub.md +12 -0
- package/docs/text/{symfill.md → SymFill.md} +1 -1
- package/docs/text/{symline.md → SymLine.md} +0 -2
- package/docs/text/{sympoints.md → SymPoints.md} +3 -3
- package/docs/text/Tables.md +11 -0
- package/docs/text/{text.md → Text.md} +4 -2
- package/docs/text/{titleframe.md → TitleFrame.md} +1 -1
- package/gala/code/atomic_orbitals.jsx +108 -0
- package/gala/code/complex_plot.jsx +21 -0
- package/gala/code/macro_economy.jsx +28 -0
- package/{docs/gala → gala/code}/metal_grid.jsx +3 -3
- package/gala/code/particle_box.jsx +55 -0
- package/gala/code/pendulum_physics.jsx +70 -0
- package/{docs/gala → gala/code}/plot_manual.jsx +2 -2
- package/{docs/gala → gala/code}/polygon_slide.jsx +4 -4
- package/gala/code/set_theory.jsx +11 -0
- package/{docs/gala → gala/code}/slick_bars.jsx +4 -4
- package/gala/code/spline_star.jsx +18 -0
- package/gala/code/stokes_theorem.jsx +151 -0
- package/gala/text/atomic_orbitals.md +7 -0
- package/gala/text/complex_plot.md +7 -0
- package/gala/text/flux_capacitance.md +5 -0
- package/gala/text/macro_economy.md +7 -0
- package/gala/text/metal_grid.md +7 -0
- package/gala/text/particle_box.md +7 -0
- package/gala/text/pendulum_physics.md +7 -0
- package/gala/text/plot_manual.md +5 -0
- package/gala/text/polygon_slide.md +7 -0
- package/gala/text/punk_rock.md +5 -0
- package/gala/text/set_theory.md +5 -0
- package/gala/text/slick_bars.md +7 -0
- package/gala/text/spline_star.md +7 -0
- package/gala/text/stokes_theorem.md +7 -0
- package/gala/text/the_nexus.md +5 -0
- package/package.json +28 -34
- package/prompt/docs.md +1 -1
- package/prompt/gen.md +101 -0
- package/prompt/intro.md +65 -15
- package/prompt/refs.md +36 -1
- package/scripts/claude.ts +25 -0
- package/scripts/gum.ts +376 -0
- package/scripts/skill.ts +75 -0
- package/scripts/test.ts +41 -0
- package/skills/gum-jsx/SKILL.md +502 -0
- package/skills/gum-jsx/references/gala/atomic_orbitals.md +120 -0
- package/skills/gum-jsx/references/gala/complex_plot.md +33 -0
- package/skills/gum-jsx/references/gala/flux_capacitance.md +15 -0
- package/skills/gum-jsx/references/gala/macro_economy.md +40 -0
- package/skills/gum-jsx/references/gala/metal_grid.md +29 -0
- package/skills/gum-jsx/references/gala/particle_box.md +67 -0
- package/skills/gum-jsx/references/gala/pendulum_physics.md +82 -0
- package/skills/gum-jsx/references/gala/plot_manual.md +21 -0
- package/skills/gum-jsx/references/gala/polygon_slide.md +42 -0
- package/skills/gum-jsx/references/gala/punk_rock.md +17 -0
- package/skills/gum-jsx/references/gala/set_theory.md +21 -0
- package/skills/gum-jsx/references/gala/slick_bars.md +24 -0
- package/skills/gum-jsx/references/gala/spline_star.md +30 -0
- package/skills/gum-jsx/references/gala/stokes_theorem.md +163 -0
- package/skills/gum-jsx/references/gala/the_nexus.md +24 -0
- package/skills/gum-jsx/references/geometry.md +231 -0
- package/skills/gum-jsx/references/layout.md +135 -0
- package/skills/gum-jsx/references/math.md +145 -0
- package/skills/gum-jsx/references/networks.md +90 -0
- package/skills/gum-jsx/references/plotting.md +138 -0
- package/skills/gum-jsx/references/symbolic.md +141 -0
- package/skills/gum-jsx/references/text.md +94 -0
- package/skills/gum-jsx/references/utilities.md +181 -0
- package/src/elems/core.ts +759 -0
- package/src/elems/geometry.ts +725 -0
- package/src/elems/image.ts +165 -0
- package/src/elems/layout.ts +530 -0
- package/src/elems/math.ts +1211 -0
- package/src/elems/network.ts +173 -0
- package/src/elems/plot.ts +780 -0
- package/src/elems/slide.ts +124 -0
- package/src/elems/symbolic.ts +345 -0
- package/src/elems/text.ts +311 -0
- package/src/eval.ts +156 -0
- package/src/fonts/fonts.ts +68 -0
- package/src/gum.ts +63 -0
- package/src/lib/const.ts +54 -0
- package/src/lib/interp.ts +170 -0
- package/src/{parse.js → lib/parse.ts} +133 -32
- package/src/lib/rng.ts +97 -0
- package/src/lib/symbols.ts +870 -0
- package/src/lib/table.ts +25 -0
- package/src/lib/text.ts +179 -0
- package/src/lib/theme.ts +135 -0
- package/src/lib/types.ts +56 -0
- package/src/lib/utils.ts +918 -0
- package/src/lib/wrap.ts +48 -0
- package/src/meta.ts +80 -0
- package/src/render.ts +126 -0
- package/src/types/katex.d.ts +128 -0
- package/src/types/linebreak.d.ts +13 -0
- package/src/types/opentype.d.ts +381 -0
- package/docs/code/context.jsx +0 -7
- package/docs/code/ellipse.jsx +0 -6
- package/docs/code/group.jsx +0 -5
- package/docs/code/math.jsx +0 -6
- package/docs/code/symfield.jsx +0 -4
- package/docs/code/triangle.jsx +0 -7
- package/docs/gala/complex_plot.jsx +0 -21
- package/docs/gala/set_theory.jsx +0 -11
- package/docs/gala/spline_star.jsx +0 -20
- package/docs/text/axis.md +0 -20
- package/docs/text/context.md +0 -17
- package/docs/text/edge.md +0 -16
- package/docs/text/graph.md +0 -10
- package/docs/text/group.md +0 -14
- package/docs/text/latex.md +0 -9
- package/docs/text/points.md +0 -11
- package/docs/text/triangle.md +0 -5
- package/index.d.ts +0 -1271
- package/scripts/cli.js +0 -48
- package/scripts/mcp.js +0 -52
- package/src/defaults.js +0 -177
- package/src/eval.js +0 -81
- package/src/fonts/IBMPlexMono-Bold.ttf +0 -0
- package/src/fonts/NotoColorEmoji-Regular.ttf +0 -0
- package/src/fonts.browser.js +0 -16
- package/src/fonts.js +0 -32
- package/src/fonts.node.js +0 -17
- package/src/gum.js +0 -3416
- package/src/math.js +0 -123
- package/src/meta.js +0 -47
- package/src/render.js +0 -54
- package/src/term.js +0 -71
- package/src/text.js +0 -173
- package/src/utils.js +0 -384
- /package/docs/code/{axis.jsx → Axis.jsx} +0 -0
- /package/docs/code/{box.jsx → Box.jsx} +0 -0
- /package/docs/code/{gum.jsx → Gum.jsx} +0 -0
- /package/docs/code/{plot.jsx → Plot.jsx} +0 -0
- /package/docs/code/{slide.jsx → Slide.jsx} +0 -0
- /package/docs/code/{symfill.jsx → SymFill.jsx} +0 -0
- /package/docs/code/{symline.jsx → SymLine.jsx} +0 -0
- /package/docs/code/{symshape.jsx → SymShape.jsx} +0 -0
- /package/docs/code/{textbox.jsx → TextBox.jsx} +0 -0
- /package/docs/code/{titleframe.jsx → TitleFrame.jsx} +0 -0
- /package/docs/text/{ellipse.md → Ellipse.md} +0 -0
- /package/docs/text/{grid.md → Grid.md} +0 -0
- /package/docs/text/{rect.md → Rect.md} +0 -0
- /package/docs/text/{slide.md → Slide.md} +0 -0
- /package/docs/text/{symshape.md → SymShape.md} +0 -0
- /package/docs/text/{symspline.md → SymSpline.md} +0 -0
- /package/docs/text/{textbox.md → TextBox.md} +0 -0
- /package/docs/text/{unitline.md → UnitLine.md} +0 -0
- /package/{docs/gala → gala/code}/flux_capacitance.jsx +0 -0
- /package/{docs/gala → gala/code}/punk_rock.jsx +0 -0
- /package/{docs/gala → gala/code}/the_nexus.jsx +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2026 Compendium Labs
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<img src="image/logo.
|
|
2
|
+
<img src="image/logo.png" alt="logo" width="500" />
|
|
3
3
|
<br/>
|
|
4
4
|
</div>
|
|
5
5
|
|
|
@@ -15,7 +15,7 @@ Head to **[compendiumlabs.ai/gum](https://compendiumlabs.ai/gum)** for a live de
|
|
|
15
15
|
# Installation
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
|
|
18
|
+
bun i gum-jsx
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
# Usage
|
|
@@ -38,7 +38,7 @@ const svg = elem.svg()
|
|
|
38
38
|
|
|
39
39
|
Which will produce the following:
|
|
40
40
|
|
|
41
|
-
<img src="image/plot.
|
|
41
|
+
<img src="image/plot.png" alt="sine wave plot" width="750" />
|
|
42
42
|
|
|
43
43
|
You can also use JavaScript directly:
|
|
44
44
|
|
|
@@ -53,23 +53,23 @@ const svg = elem.svg()
|
|
|
53
53
|
|
|
54
54
|
# CLI
|
|
55
55
|
|
|
56
|
-
You can use the `gum` command to convert `gum.jsx` into SVG text or PNG data.
|
|
56
|
+
You can use the `gum` command to convert `gum.jsx` into SVG text or PNG data. You can even just display it directly in the terminal! For the latter you need a terminal that supports images, such as `ghostty` or `kitty`. There are a bunch of code examples in `docs/code/` and `docs/gallery/` to try out.
|
|
57
57
|
|
|
58
58
|
Generate an SVG from a `gum.jsx` file:
|
|
59
59
|
|
|
60
60
|
```bash
|
|
61
|
-
cat input.jsx |
|
|
61
|
+
cat input.jsx | bun run cli -f svg > output.svg
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
Generate a PNG from a `gum.jsx` file:
|
|
65
65
|
|
|
66
66
|
```bash
|
|
67
|
-
cat input.jsx |
|
|
67
|
+
cat input.jsx | bun run cli -f png > output.png
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
Display a `gum.jsx` file
|
|
70
|
+
Display a `gum.jsx` file in the terminal:
|
|
71
71
|
```bash
|
|
72
|
-
cat input.jsx |
|
|
72
|
+
cat input.jsx | bun run cli
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
CLI options:
|
|
@@ -78,3 +78,9 @@ CLI options:
|
|
|
78
78
|
|--------|-------------|---------|
|
|
79
79
|
| `-s, --size <size>` | Image size in pixels | 500 |
|
|
80
80
|
| `-t, --theme <theme>` | Theme: `light` or `dark` | light |
|
|
81
|
+
| `-w, --width <width>` | Width of the PNG | null |
|
|
82
|
+
| `-h, --height <height>` | Height of the PNG | null |
|
|
83
|
+
| `-f, --format <format>` | Format: `svg` or `png` | `svg` |
|
|
84
|
+
| `-b, --background <color>` | Background color | null (transparent) |
|
|
85
|
+
| `-o, --output <output>` | Output file | null (stdout) |
|
|
86
|
+
| `-u, --update` | Live update display | false |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// a scatter plot of points with emojis for: mount fuji, a rocket, a whale, a watermellon, and a donut
|
|
2
2
|
<Plot xlim={[0, 6]} ylim={[0, 6]} xticks={7} yticks={7} margin={0.15}>
|
|
3
3
|
{ [ '🗻', '🚀', '🐋', '🍉', '🍩' ].map((e, i) =>
|
|
4
|
-
<Text pos={[i+1, i+1]}
|
|
4
|
+
<Text pos={[i+1, i+1]} size={0.8}>{e}</Text>
|
|
5
5
|
) }
|
|
6
6
|
</Plot>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// the text "Blue Square" on the left with an arrow pointing to a blue square on the right
|
|
2
|
+
<Frame rounded>
|
|
3
|
+
<Group aspect={2}>
|
|
4
|
+
<Text pos={[0.2, 0.5]} ysize={0.2} wrap={4} justify="center">Blue Square</Text>
|
|
5
|
+
<Arrow points={[[0.3, 0.5], [0.6, 0.5]]} />
|
|
6
|
+
<Square pos={[0.75, 0.5]} ysize={0.5} rounded fill={blue} />
|
|
7
|
+
</Group>
|
|
8
|
+
</Frame>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// A plot with three bars with black borders at "A", "B", and "C". The first bar is red and is the shortest, the second bar is blue and is the tallest, while the third bar is green and its height is in between.
|
|
2
2
|
<BarPlot ylim={[0, 10]} yticks={6} ygrid title="Example BarPlot" xlabel="Category" ylabel="Value" margin={0.25}>
|
|
3
|
-
<Bar label="A"
|
|
4
|
-
<Bar label="B"
|
|
5
|
-
<Bar label="C"
|
|
3
|
+
<Bar label="A" value={3} fill={red} />
|
|
4
|
+
<Bar label="B" value={8.5} fill={blue} />
|
|
5
|
+
<Bar label="C" value={6.5} fill={green} />
|
|
6
6
|
</BarPlot>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// A plot of an inverted sine wave where the line markers are sized in proportion to the amplitude and the color ranges from blue to red depending on the phase. The x-axis ticks are labeled with multiples of π. The x-axis is labeled "phase" and the y-axis is labeled "amplitude". The title is "Inverted Sine Wave".
|
|
2
2
|
const func = x => -sin(x)
|
|
3
3
|
const pal = palette(blue, red, [-1, 1])
|
|
4
|
-
const size = (x, y) => 0.
|
|
4
|
+
const size = (x, y) => 0.2 * (1+abs(y))/2
|
|
5
5
|
const shape = (x, y) => <Circle fill={pal(y)} />
|
|
6
6
|
const xticks = linspace(0, 2, 6).slice(1).map(x => [x*pi, `${rounder(x, 1)} π`])
|
|
7
7
|
return <Plot xlim={[0, 2*pi]} ylim={[-1, 1]} aspect={1.5} xanchor={0} xaxis-tick-side="both" xticks={xticks} grid xlabel="phase" ylabel="amplitude" title="Inverted Sine Wave" margin={0.25}>
|
|
8
8
|
<SymLine fy={func} />
|
|
9
|
-
<SymPoints fy={func} size={size} shape={shape} N={21}>
|
|
9
|
+
<SymPoints fy={func} point-size={size} point-shape={shape} N={21}>
|
|
10
10
|
</SymPoints>
|
|
11
11
|
</Plot>
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
<Network aspect node-fill={gray} edge-arrow>
|
|
3
3
|
<Node id="hello" pos={[0.25, 0.25]}>Hello</Node>
|
|
4
4
|
<Node id="world" pos={[0.75, 0.75]}>World!</Node>
|
|
5
|
-
<Edge
|
|
5
|
+
<Edge start="hello" end="world" start-fill={red} end-fill={blue} />
|
|
6
6
|
</Network>
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// create a custom triangle element called `Tri` and use it to create a triangle with a gray fill
|
|
2
|
-
const Tri = ({ pos0, pos1, pos2, ...attr }) => <Shape {...attr}
|
|
2
|
+
const Tri = ({ pos0, pos1, pos2, ...attr }) => <Shape {...attr} points={[pos0, pos1, pos2]} />
|
|
3
3
|
return <Tri pos0={[0.5, 0.1]} pos1={[0.9, 0.9]} pos2={[0.1, 0.9]} fill={gray} />
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// shade the area between a zigzag curve and the x-axis
|
|
2
|
+
const curve = [[0, 1], [2, 3], [4, 2], [6, 5], [8, 4], [10, 6]]
|
|
3
|
+
return <Graph xlim={[0, 10]} ylim={[0, 7]} aspect={phi}>
|
|
4
|
+
<VFill points1={curve} points2={0} fill={blue} fill-opacity={0.4} />
|
|
5
|
+
<Line points={curve} stroke={blue} />
|
|
6
|
+
</Graph>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// a fraction with x + 1 over y - 1
|
|
2
|
+
<Frac>
|
|
3
|
+
<MathText>
|
|
4
|
+
<MathSymbol>x</MathSymbol>
|
|
5
|
+
<MathSymbol>{'+'}</MathSymbol>
|
|
6
|
+
<MathSymbol>1</MathSymbol>
|
|
7
|
+
</MathText>
|
|
8
|
+
<MathText>
|
|
9
|
+
<MathSymbol>y</MathSymbol>
|
|
10
|
+
<MathSymbol>{'-'}</MathSymbol>
|
|
11
|
+
<MathSymbol>1</MathSymbol>
|
|
12
|
+
</MathText>
|
|
13
|
+
</Frac>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// a series of closely spaced squares rotating clockwise along a sinusoidal path
|
|
2
2
|
<Graph ylim={[-1.5, 1.5]} padding={0.2} aspect={2}>
|
|
3
3
|
<SymPoints
|
|
4
|
-
fy={sin} xlim={[0, 2*pi]} size={
|
|
5
|
-
shape={x => <Square rounded spin={r2d*x} />}
|
|
4
|
+
fy={sin} xlim={[0, 2*pi]} point-size={1} N={100}
|
|
5
|
+
point-shape={x => <Square rounded spin={r2d*x} />}
|
|
6
6
|
/>
|
|
7
|
-
</Graph>
|
|
7
|
+
</Graph>
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
<Frame padding rounded>
|
|
3
3
|
<Grid rows={3} spacing>
|
|
4
4
|
{ linspace(0, 360, 10).slice(0, 9).map(th =>
|
|
5
|
-
<Frame padding rounded
|
|
5
|
+
<Frame padding rounded>
|
|
6
6
|
<Group aspect={1} spin={th}>
|
|
7
|
-
<Arrow
|
|
7
|
+
<Arrow points={[[0, 0.5], [1, 0.5]]} arrow-size={0.4} />
|
|
8
8
|
</Group>
|
|
9
9
|
</Frame>
|
|
10
10
|
) }
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
// There are two latex equations framed by rounded borders arranged vertically. The top one shows a Gaussian integral and the bottom one shows a trigonometric identity. They are framed by a square with the title "Facts".
|
|
2
2
|
<VStack spacing>
|
|
3
|
-
<TextFrame
|
|
4
|
-
|
|
3
|
+
<TextFrame rounded border={2}>
|
|
4
|
+
<Latex>{"\\int_0^{\\infty} \\exp(-x^2) dx = \\sqrt{\\pi}"}</Latex>
|
|
5
|
+
</TextFrame>
|
|
6
|
+
<TextFrame rounded border={2}>
|
|
7
|
+
<Latex>{"\\sin^2(\\theta) + \\cos^2(\\theta) = 1"}</Latex>
|
|
8
|
+
</TextFrame>
|
|
5
9
|
</VStack>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// draw a diagonal line in blue and a cup shaped line in red
|
|
2
2
|
<Group>
|
|
3
|
-
<Line stroke={blue}
|
|
3
|
+
<Line stroke={blue} points={[
|
|
4
4
|
[0.2, 0.2],
|
|
5
5
|
[0.8, 0.8],
|
|
6
|
-
]}
|
|
7
|
-
<Line stroke={red}
|
|
6
|
+
]} />
|
|
7
|
+
<Line stroke={red} points={[
|
|
8
8
|
[0.3, 0.3],
|
|
9
9
|
[0.3, 0.7],
|
|
10
10
|
[0.7, 0.7],
|
|
11
11
|
[0.7, 0.3],
|
|
12
|
-
]}
|
|
12
|
+
]} />
|
|
13
13
|
</Group>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// use polar to place points around a circle
|
|
2
|
+
const center = [0.5, 0.5]
|
|
3
|
+
const ring = range(10).map(i => {
|
|
4
|
+
const radius = i % 2 == 0 ? 0.32 : 0.16
|
|
5
|
+
return polar([radius, -90 + 36 * i], center)
|
|
6
|
+
})
|
|
7
|
+
const spokes = range(5).map(i => polar([0.32, -90 + 72 * i], center))
|
|
8
|
+
|
|
9
|
+
return <Group aspect={1}>
|
|
10
|
+
<Circle pos={center} size={0.64} stroke={darkgray} />
|
|
11
|
+
<Shape points={ring} stroke={blue} stroke-width={2} />
|
|
12
|
+
{spokes.map(pos => <Line points={[center, pos]} stroke={red} stroke-width={1.5} />)}
|
|
13
|
+
{ring.map(pos => <Dot pos={pos} size={0.03} fill={blue} />)}
|
|
14
|
+
</Group>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// a MathText row expressing "alpha = blue x red" where blue and red are represented by squares
|
|
2
|
+
<TextFrame rounded>
|
|
3
|
+
<MathText>
|
|
4
|
+
<MathSymbol>\alpha</MathSymbol>
|
|
5
|
+
<MathSymbol>=</MathSymbol>
|
|
6
|
+
<Square rounded fill={blue} />
|
|
7
|
+
<MathSymbol>\times</MathSymbol>
|
|
8
|
+
<Square rounded fill={red} />
|
|
9
|
+
</MathText>
|
|
10
|
+
</TextFrame>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// A network with a node on the left saying "Hello world" and two nodes on the right, one saying "This is a test of wrapping capabilities" and the other containing a blue ellipse. There are arrows going from the left node to each of the right nodes. The nodes have gray backgrounds and rounded corners. The edges have white arrowheads.
|
|
2
|
-
<Network aspect={1.5} node-
|
|
2
|
+
<Network aspect={1.5} node-ysize={0.3} node-rounded node-fill={gray} edge-fill={white}>
|
|
3
3
|
<Node id="hello" pos={[0.25, 0.5]} wrap={3}>Hello world</Node>
|
|
4
4
|
<Node id="test" pos={[0.75, 0.25]} wrap={6}>This is a test of wrapping capabilities</Node>
|
|
5
5
|
<Node id="ball" pos={[0.75, 0.75]}><Ellipse aspect={1.5} fill={blue}/></Node>
|
|
6
|
-
<Edge
|
|
7
|
-
<Edge
|
|
6
|
+
<Edge start="hello" end="test" />
|
|
7
|
+
<Edge start="hello" end="ball" start-side="s" curve={3} />
|
|
8
8
|
</Network>
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// A plot of three different increasing curves of varying steepness and multiple points spaced at regular intervals. The x-axis label is "time (seconds)", the y-axis label is "space (meters)", and the title is "Spacetime Vibes". There are axis ticks in both directions with assiated faint grid lines.
|
|
2
2
|
<Plot xlim={[-1, 1]} ylim={[-1, 1]} grid margin={0.3} aspect xlabel="time (seconds)" ylabel="space (meters)" title="Spacetime Vibes">
|
|
3
|
-
<Points size={0.
|
|
3
|
+
<Points point-size={0.04} points={[
|
|
4
4
|
[0, 0.5], [0.5, 0], [-0.5, 0], [0, -0.5]
|
|
5
|
-
]}
|
|
6
|
-
|
|
7
|
-
<
|
|
8
|
-
<Circle pos={[-0.5, -0.5]} rad={0.1} />
|
|
5
|
+
]} />
|
|
6
|
+
<Rectangle pos={[0.5, 0.5]} size={0.2} />
|
|
7
|
+
<Circle pos={[-0.5, -0.5]} size={0.2} />
|
|
9
8
|
{[0.5, 0.9, 1.5].map(a =>
|
|
10
9
|
<SymLine fy={x => sin(a*x)} />
|
|
11
10
|
)}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// a rectangle on the left side of the figure with an aspect of roughly 1/2
|
|
2
|
-
<
|
|
2
|
+
<Rectangle pos={[0.25, 0.5]} size={[0.2, 0.4]}/>
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// draw a blue triangle with a semi-transparent green square overlaid on top
|
|
2
2
|
<Group>
|
|
3
|
-
<Shape fill={blue} stroke={none}
|
|
3
|
+
<Shape fill={blue} stroke={none} points={[
|
|
4
4
|
[0.5, 0.2],
|
|
5
5
|
[0.8, 0.8],
|
|
6
6
|
[0.2, 0.8]
|
|
7
|
-
]}
|
|
8
|
-
<Shape fill={green} stroke={none} opacity={0.5}
|
|
7
|
+
]} />
|
|
8
|
+
<Shape fill={green} stroke={none} opacity={0.5} points={[
|
|
9
9
|
[0.3, 0.3],
|
|
10
10
|
[0.7, 0.3],
|
|
11
11
|
[0.7, 0.7],
|
|
12
12
|
[0.3, 0.7]
|
|
13
|
-
]}
|
|
13
|
+
]} />
|
|
14
14
|
</Group>
|
|
@@ -7,7 +7,7 @@ const points = [
|
|
|
7
7
|
[0.50, 0.50],
|
|
8
8
|
]
|
|
9
9
|
return <Frame rounded margin>
|
|
10
|
-
<Spline closed stroke={blue} fill={gray}
|
|
11
|
-
<Shape stroke={red}
|
|
12
|
-
<Points size={0.
|
|
10
|
+
<Spline closed stroke={blue} fill={gray} points={points} />
|
|
11
|
+
<Shape stroke={red} points={points} />
|
|
12
|
+
<Points point-size={0.02} points={points} />
|
|
13
13
|
</Frame>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// a wide blue rectangle on top, with red and green squares side by side on the bottom. each one has rounded corners.
|
|
2
2
|
<VStack spacing>
|
|
3
|
-
<
|
|
4
|
-
<HStack
|
|
3
|
+
<Rectangle rounded aspect={2} fill={blue} />
|
|
4
|
+
<HStack spacing>
|
|
5
5
|
<Square rounded fill={red} />
|
|
6
6
|
<Square rounded fill={green} />
|
|
7
7
|
</HStack>
|
|
8
|
-
</VStack>
|
|
8
|
+
</VStack>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// A vector field showing a function with gradient 100 * x * y. There should be a grid of 15 by 15 arrows. The stroke width should be 2.
|
|
2
|
+
<Frame rounded={0.02} margin padding={0.075}>
|
|
3
|
+
<SymField func={(x, y) => 100 * x * y} xlim={[0, 1]} ylim={[0, 1]} N={15} />
|
|
4
|
+
</Frame>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// A plot of a sine wave in blue. There are white pill shaped line markers along the sine wave that are rotated to follow the slope of the curve.
|
|
2
|
-
const Pill = args => <
|
|
2
|
+
const Pill = args => <Rectangle fill={white} rounded={0.3} aspect={2} {...args} />
|
|
3
3
|
return <Plot xlim={[0, 2*pi]} ylim={[-1.5, 1.5]} grid fill={lightgray} margin={[0.25, 0.1]} aspect="auto">
|
|
4
4
|
<SymLine fy={sin} stroke={blue} stroke-width={2} />
|
|
5
|
-
<SymPoints fy={sin}
|
|
5
|
+
<SymPoints fy={sin} N={11} point-size={0.25} point-shape={x => <Pill spin={-r2d*atan(cos(x))}/>} />
|
|
6
6
|
</Plot>
|
|
@@ -6,5 +6,5 @@ const decay = x => exp(-x/2) * sin(3*x)
|
|
|
6
6
|
return <Plot xlim={[0, 2*pi]} ylim={[-1, 1]} grid margin={0.15} aspect={phi}>
|
|
7
7
|
<SymLine fy={decay} opacity={0.25} N={200} />
|
|
8
8
|
<SymSpline fy={decay} N={10} stroke={blue} stroke-width={2} />
|
|
9
|
-
<SymPoints fy={decay} N={10} size={0.
|
|
9
|
+
<SymPoints fy={decay} N={10} point-size={0.1} fill={red} />
|
|
10
10
|
</Plot>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// The text "Hello World! You can mix text and other elements together." with a blue square between "and" and "other". Put it in a rounded frame with padding.
|
|
2
|
-
<TextFrame rounded wrap={10}>
|
|
2
|
+
<TextFrame rounded wrap={10} justify="center">
|
|
3
3
|
Hello World! You can mix text and <Square rounded fill={blue} /> other elements together.
|
|
4
4
|
</TextFrame>
|
|
Binary file
|
package/docs/meta.json
CHANGED
|
@@ -1,50 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"core": [
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"context"
|
|
3
|
+
"Gum",
|
|
4
|
+
"Element",
|
|
5
|
+
"Group"
|
|
7
6
|
],
|
|
8
7
|
"layout": [
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
],
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
8
|
+
"Box",
|
|
9
|
+
"Stack",
|
|
10
|
+
"Grid",
|
|
11
|
+
"Points"
|
|
12
|
+
],
|
|
13
|
+
"geometry": [
|
|
14
|
+
"Rect",
|
|
15
|
+
"Ellipse",
|
|
16
|
+
"Arc",
|
|
17
|
+
"Line",
|
|
18
|
+
"Shape",
|
|
19
|
+
"Fill",
|
|
20
|
+
"Spline",
|
|
21
|
+
"Arrow"
|
|
20
22
|
],
|
|
21
23
|
"text": [
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
24
|
+
"Text",
|
|
25
|
+
"TitleFrame",
|
|
26
|
+
"Slide"
|
|
27
|
+
],
|
|
28
|
+
"math": [
|
|
29
|
+
"Latex",
|
|
30
|
+
"MathText",
|
|
31
|
+
"SupSub",
|
|
32
|
+
"Frac",
|
|
33
|
+
"Bracket"
|
|
26
34
|
],
|
|
27
35
|
"symbolic": [
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
36
|
+
"SymPoints",
|
|
37
|
+
"SymLine",
|
|
38
|
+
"SymShape",
|
|
39
|
+
"SymSpline",
|
|
40
|
+
"SymFill"
|
|
33
41
|
],
|
|
34
42
|
"plotting": [
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
43
|
+
"Graph",
|
|
44
|
+
"Plot",
|
|
45
|
+
"Axis",
|
|
46
|
+
"BarPlot"
|
|
39
47
|
],
|
|
40
48
|
"networks": [
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
49
|
+
"Node",
|
|
50
|
+
"Edge",
|
|
51
|
+
"Network"
|
|
44
52
|
],
|
|
45
53
|
"utilities": [
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
54
|
+
"Math",
|
|
55
|
+
"Arrays",
|
|
56
|
+
"Colors",
|
|
57
|
+
"Tables",
|
|
58
|
+
"Images"
|
|
49
59
|
]
|
|
50
60
|
}
|
package/docs/text/Arc.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Arc
|
|
2
|
+
|
|
3
|
+
*Inherits*: [Element](/docs/Element)
|
|
4
|
+
|
|
5
|
+
This draws an elliptical arc that inscribes its allocated rectangle, like [Ellipse](/docs/Ellipse), but only over a selected angular interval.
|
|
6
|
+
|
|
7
|
+
Parameters:
|
|
8
|
+
- `degrees` = `[0, 360]` — start and end angle in degrees
|
|
9
|
+
- `range` — alias for `degrees`
|
|
10
|
+
|
|
11
|
+
Angles follow gum's usual screen-space convention: `0` points right and `90` points down.
|
|
@@ -12,8 +12,6 @@ There are a number of functions designed to make working with arrays easier. The
|
|
|
12
12
|
- `sum(arr)` — sum the elements of array `arr`
|
|
13
13
|
- `all(arr)` — check if all elements of array `arr` are true
|
|
14
14
|
- `any(arr)` — check if any element of array `arr` is true
|
|
15
|
-
- `add(arr1, arr2)` — add arrays `arr1` and `arr2` element-wise
|
|
16
|
-
- `mul(arr1, arr2)` — multiply arrays `arr1` and `arr2` element-wise
|
|
17
15
|
- `cumsum(arr, first=true)` — compute the cumulative sum of array `arr` with the option to start at zero
|
|
18
16
|
- `norm(arr, degree=1)` — compute the `degree`-norm of array `arr`
|
|
19
17
|
- `normalize(arr, degree=1)` — normalize array `arr` to have `degree`-norm one
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Arrow
|
|
2
|
+
|
|
3
|
+
*Inherits*: [Group](/docs/Group) > [Element](/docs/Element)
|
|
4
|
+
|
|
5
|
+
Draws a straight arrow between two points. This is the straight-line counterpart to [ArrowSpline](/docs/ArrowSpline): it uses `from` and `to` endpoints, but renders a simple [Line](/docs/Line) shaft instead of a curved spline.
|
|
6
|
+
|
|
7
|
+
The line and arrowhead can be styled separately using prefixed parameters. The head is built from **ArrowHead**-style geometry, while the shaft is a simple [Line](/docs/Line).
|
|
8
|
+
|
|
9
|
+
The arrow direction is inferred automatically from `from` to `to`.
|
|
10
|
+
|
|
11
|
+
Parameters:
|
|
12
|
+
- `points` — the points to draw the arrow between (can include intermediate points)
|
|
13
|
+
- `start-dir` / `end-dir` — the direction of the arrowheads at the start and end
|
|
14
|
+
- `arrow` / `arrow-start` / `arrow-end` — toggles whether the respective arrowheads are included. Defaults to `true` for `arrow-end` and `false` for `arrow-start`, meaning a directed graph edge
|
|
15
|
+
- `arrow-size` = `0.04` — size of the arrowhead
|
|
16
|
+
- `curve` = `null` — curvature factor forwarded to the spline (`null` or zero means straight line)
|
|
17
|
+
|
|
18
|
+
Subunit names:
|
|
19
|
+
- `line` — forwarded to the shaft line
|
|
20
|
+
- `arrow` — forwarded to the arrowhead
|
|
21
|
+
- `start` / `end` — forwarded to the start and end arrowheads respectively
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Axis
|
|
2
|
+
|
|
3
|
+
*Inherits*: [Group](/docs/Group) > [Element](/docs/Element)
|
|
4
|
+
|
|
5
|
+
A single vertical or horizontal axis for plotting. This includes the central line, the perpendicular ticks, and their associated tick labels. Note that the proper bounds encompass only the central line and ticks, while the tick labels may fall well outside of them. Use **HAxis** and **VAxis** for specific directions.
|
|
6
|
+
|
|
7
|
+
Because `Axis` is used primarily for [Plot](/docs/Plot), the `tick-side` parameter is inverted for `VAxis`, meaning `outer` points up and `inner` points down. Meanwhile, for `HAxis`, `outer` points to the left and `inner` points to the right.
|
|
8
|
+
|
|
9
|
+
Parameters:
|
|
10
|
+
- `direc` — the orientation of the axis, either `v` (vertical) or `h` (horizontal)
|
|
11
|
+
- `ticks` — either an integer for evenly spaced ticks, a list of tick locations, or a list of tick `[location, label]` pairs
|
|
12
|
+
- `lim` = `[0, 1]` — the extent of the element along the main axis
|
|
13
|
+
- `tick-side` = `'inner'` — one of `'inner'` / `'outer'` / `'both'` / `'none'`, or a pair representing a numerical range in `[0, 1]`, where zero is oriented in the inner direction
|
|
14
|
+
- `label-side` = `'outer'` — same as `tick-side` but for the labels
|
|
15
|
+
- `label-size` = `1.5` — the cross-axis extent allocated for labels
|
|
16
|
+
- `label-offset` = `0.75` — the gap between the ticks and the labels
|
|
17
|
+
- `label-justify` — horizontal justification for labels (defaults to `'right'` for `VAxis` outer labels)
|
|
18
|
+
- `prec` — the number of significant digits for auto-generated tick labels
|
|
19
|
+
- `children` — a list of elements to use instead of those generated by `ticks`. Each label must have a `loc` to place it and its associated tick. Labels can optionally carry a `tick` element and `tick-size` to customize their tick marks (see below).
|
|
20
|
+
|
|
21
|
+
Child parameters:
|
|
22
|
+
- `loc` — the position along the axis at which to place the tick and label
|
|
23
|
+
- `tick` — an optional custom **Element** to use as the tick mark instead of the default line
|
|
24
|
+
- `tick-size` = `1` — a fraction controlling the length of the tick mark relative to the full tick extent, respecting `tick-side`
|
|
25
|
+
|
|
26
|
+
Subunits:
|
|
27
|
+
- `line`: the central line along the main axis
|
|
28
|
+
- `tick`: the perpendicular tick marks
|
|
29
|
+
- `label`: the labels annotating the tick marks
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
*Inherits*: [Plot](/docs/Plot) > [Group](/docs/Group) > [Element](/docs/Element)
|
|
4
4
|
|
|
5
|
-
Makes a plot featuring a bar graph. This largely wraps the functionality of [Plot](/docs/plot) but takes care of labelling and arranging the `xaxis` information. You can provide `label` and `
|
|
5
|
+
Makes a plot featuring a bar graph. This largely wraps the functionality of [Plot](/docs/plot) but takes care of labelling and arranging the `xaxis` information. You can provide `label` and `value` attributes to the child elements. The **Bar**/**VBar**/**HBar** elements are just very thin wrappers around **Rect** elements, and you can use other elements in their place if you wish.
|
|
6
6
|
|
|
7
7
|
To layout just the bars without axes, use the **Bars** element directly, which this wraps using **Plot**. This way, you can plot other elements alongside the bars, such as labels or error bars. By default, the bars will be placed at `[0, ..., N-1]` along the x-axis.
|
|
8
8
|
|
|
9
9
|
Child parameters:
|
|
10
10
|
- `label` — the label for the bar
|
|
11
|
-
- `
|
|
11
|
+
- `value` — the height of the bar
|
|
12
12
|
|
|
13
13
|
Parameters:
|
|
14
14
|
- `direc` = `v` — the orientation of the bars in the plot
|