gum-jsx 1.4.0 → 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.
Files changed (205) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +2 -2
  3. package/docs/code/Arc.jsx +5 -0
  4. package/docs/code/{arrays.jsx → Arrays.jsx} +1 -1
  5. package/docs/code/Arrow.jsx +8 -0
  6. package/docs/code/{barplot.jsx → BarPlot.jsx} +3 -3
  7. package/docs/code/Bracket.jsx +7 -0
  8. package/docs/code/{colors.jsx → Colors.jsx} +2 -2
  9. package/docs/code/{edge.jsx → Edge.jsx} +1 -1
  10. package/docs/code/{element.jsx → Element.jsx} +1 -1
  11. package/docs/code/Ellipse.jsx +5 -0
  12. package/docs/code/Fill.jsx +6 -0
  13. package/docs/code/Frac.jsx +13 -0
  14. package/docs/code/{graph.jsx → Graph.jsx} +3 -3
  15. package/docs/code/{grid.jsx → Grid.jsx} +2 -2
  16. package/docs/code/Group.jsx +5 -0
  17. package/docs/code/Images.jsx +6 -0
  18. package/docs/code/{latex.jsx → Latex.jsx} +6 -2
  19. package/docs/code/{line.jsx → Line.jsx} +4 -4
  20. package/docs/code/Math.jsx +14 -0
  21. package/docs/code/MathText.jsx +10 -0
  22. package/docs/code/{network.jsx → Network.jsx} +3 -3
  23. package/docs/code/{node.jsx → Node.jsx} +1 -1
  24. package/docs/code/{points.jsx → Points.jsx} +4 -5
  25. package/docs/code/{rect.jsx → Rect.jsx} +1 -1
  26. package/docs/code/{shape.jsx → Shape.jsx} +4 -4
  27. package/docs/code/{spline.jsx → Spline.jsx} +3 -3
  28. package/docs/code/{stack.jsx → Stack.jsx} +3 -3
  29. package/docs/code/SupSub.jsx +8 -0
  30. package/docs/code/{symfield.jsx → SymField.jsx} +2 -2
  31. package/docs/code/{sympoints.jsx → SymPoints.jsx} +1 -1
  32. package/docs/code/{symspline.jsx → SymSpline.jsx} +1 -1
  33. package/docs/code/Tables.jsx +6 -0
  34. package/docs/code/{text.jsx → Text.jsx} +1 -1
  35. package/docs/code/{unitline.jsx → UnitLine.jsx} +1 -1
  36. package/docs/data/data.csv +7 -0
  37. package/docs/data/image.png +0 -0
  38. package/docs/meta.json +44 -34
  39. package/docs/text/Arc.md +11 -0
  40. package/docs/text/{arrays.md → Arrays.md} +0 -2
  41. package/docs/text/Arrow.md +21 -0
  42. package/docs/text/Axis.md +29 -0
  43. package/docs/text/{barplot.md → BarPlot.md} +2 -2
  44. package/docs/text/{box.md → Box.md} +1 -0
  45. package/docs/text/Bracket.md +12 -0
  46. package/docs/text/Edge.md +16 -0
  47. package/docs/text/{element.md → Element.md} +4 -6
  48. package/docs/text/Fill.md +16 -0
  49. package/docs/text/Frac.md +11 -0
  50. package/docs/text/{group.md → Group.md} +0 -1
  51. package/docs/text/Images.md +9 -0
  52. package/docs/text/Latex.md +9 -0
  53. package/docs/text/{line.md → Line.md} +1 -1
  54. package/docs/text/{math.md → Math.md} +4 -0
  55. package/docs/text/MathText.md +13 -0
  56. package/docs/text/{network.md → Network.md} +1 -1
  57. package/docs/text/{node.md → Node.md} +1 -1
  58. package/docs/text/Points.md +13 -0
  59. package/docs/text/{shape.md → Shape.md} +2 -1
  60. package/docs/text/{spline.md → Spline.md} +4 -2
  61. package/docs/text/{stack.md → Stack.md} +4 -3
  62. package/docs/text/SupSub.md +12 -0
  63. package/docs/text/{symfill.md → SymFill.md} +1 -1
  64. package/docs/text/{sympoints.md → SymPoints.md} +3 -3
  65. package/docs/text/Tables.md +11 -0
  66. package/docs/text/{text.md → Text.md} +4 -2
  67. package/docs/text/{titleframe.md → TitleFrame.md} +1 -1
  68. package/gala/code/atomic_orbitals.jsx +108 -0
  69. package/{docs/gala → gala/code}/complex_plot.jsx +10 -10
  70. package/gala/code/macro_economy.jsx +28 -0
  71. package/{docs/gala → gala/code}/metal_grid.jsx +2 -2
  72. package/gala/code/particle_box.jsx +55 -0
  73. package/gala/code/pendulum_physics.jsx +70 -0
  74. package/gala/code/plot_manual.jsx +11 -0
  75. package/{docs/gala → gala/code}/polygon_slide.jsx +4 -4
  76. package/gala/code/set_theory.jsx +11 -0
  77. package/{docs/gala → gala/code}/slick_bars.jsx +4 -4
  78. package/gala/code/spline_star.jsx +18 -0
  79. package/gala/code/stokes_theorem.jsx +151 -0
  80. package/gala/text/atomic_orbitals.md +7 -0
  81. package/gala/text/complex_plot.md +7 -0
  82. package/gala/text/flux_capacitance.md +5 -0
  83. package/gala/text/macro_economy.md +7 -0
  84. package/gala/text/metal_grid.md +7 -0
  85. package/gala/text/particle_box.md +7 -0
  86. package/gala/text/pendulum_physics.md +7 -0
  87. package/gala/text/plot_manual.md +5 -0
  88. package/gala/text/polygon_slide.md +7 -0
  89. package/gala/text/punk_rock.md +5 -0
  90. package/gala/text/set_theory.md +5 -0
  91. package/gala/text/slick_bars.md +7 -0
  92. package/gala/text/spline_star.md +7 -0
  93. package/gala/text/stokes_theorem.md +7 -0
  94. package/gala/text/the_nexus.md +5 -0
  95. package/package.json +16 -13
  96. package/prompt/docs.md +1 -1
  97. package/prompt/gen.md +101 -0
  98. package/prompt/intro.md +65 -15
  99. package/prompt/refs.md +36 -1
  100. package/scripts/claude.ts +3 -7
  101. package/scripts/gum.ts +376 -0
  102. package/scripts/skill.ts +28 -10
  103. package/scripts/test.ts +13 -4
  104. package/{claude/skills → skills}/gum-jsx/SKILL.md +212 -27
  105. package/skills/gum-jsx/references/gala/atomic_orbitals.md +120 -0
  106. package/skills/gum-jsx/references/gala/complex_plot.md +33 -0
  107. package/skills/gum-jsx/references/gala/flux_capacitance.md +15 -0
  108. package/skills/gum-jsx/references/gala/macro_economy.md +40 -0
  109. package/skills/gum-jsx/references/gala/metal_grid.md +29 -0
  110. package/skills/gum-jsx/references/gala/particle_box.md +67 -0
  111. package/skills/gum-jsx/references/gala/pendulum_physics.md +82 -0
  112. package/skills/gum-jsx/references/gala/plot_manual.md +21 -0
  113. package/skills/gum-jsx/references/gala/polygon_slide.md +42 -0
  114. package/skills/gum-jsx/references/gala/punk_rock.md +17 -0
  115. package/skills/gum-jsx/references/gala/set_theory.md +21 -0
  116. package/skills/gum-jsx/references/gala/slick_bars.md +24 -0
  117. package/skills/gum-jsx/references/gala/spline_star.md +30 -0
  118. package/skills/gum-jsx/references/gala/stokes_theorem.md +163 -0
  119. package/skills/gum-jsx/references/gala/the_nexus.md +24 -0
  120. package/skills/gum-jsx/references/geometry.md +231 -0
  121. package/{claude/skills → skills}/gum-jsx/references/layout.md +19 -16
  122. package/skills/gum-jsx/references/math.md +145 -0
  123. package/{claude/skills → skills}/gum-jsx/references/networks.md +18 -18
  124. package/{claude/skills → skills}/gum-jsx/references/plotting.md +23 -14
  125. package/{claude/skills → skills}/gum-jsx/references/symbolic.md +6 -6
  126. package/{claude/skills → skills}/gum-jsx/references/text.md +6 -26
  127. package/{claude/skills → skills}/gum-jsx/references/utilities.md +69 -11
  128. package/src/elems/core.ts +128 -109
  129. package/src/elems/geometry.ts +264 -139
  130. package/src/elems/image.ts +165 -0
  131. package/src/elems/layout.ts +79 -64
  132. package/src/elems/math.ts +1211 -0
  133. package/src/elems/network.ts +68 -152
  134. package/src/elems/plot.ts +204 -126
  135. package/src/elems/slide.ts +50 -19
  136. package/src/elems/symbolic.ts +48 -49
  137. package/src/elems/text.ts +136 -249
  138. package/src/eval.ts +72 -7
  139. package/src/fonts/fonts.ts +54 -20
  140. package/src/gum.ts +47 -14
  141. package/src/lib/const.ts +5 -5
  142. package/src/lib/interp.ts +170 -0
  143. package/src/lib/parse.ts +105 -12
  144. package/src/lib/rng.ts +97 -0
  145. package/src/lib/symbols.ts +870 -0
  146. package/src/lib/table.ts +25 -0
  147. package/src/lib/text.ts +58 -57
  148. package/src/lib/theme.ts +15 -20
  149. package/src/lib/types.ts +13 -6
  150. package/src/lib/utils.ts +268 -169
  151. package/src/lib/wrap.ts +48 -0
  152. package/src/meta.ts +38 -13
  153. package/src/render.ts +57 -9
  154. package/src/types/katex.d.ts +128 -0
  155. package/claude/.claude-plugin/plugin.json +0 -8
  156. package/claude/.mcp.json +0 -10
  157. package/claude/skills/gum-jsx/references/shapes.md +0 -138
  158. package/docs/code/context.jsx +0 -7
  159. package/docs/code/ellipse.jsx +0 -6
  160. package/docs/code/group.jsx +0 -5
  161. package/docs/code/math.jsx +0 -6
  162. package/docs/code/triangle.jsx +0 -7
  163. package/docs/gala/plot_manual.jsx +0 -11
  164. package/docs/gala/set_theory.jsx +0 -11
  165. package/docs/gala/spline_star.jsx +0 -20
  166. package/docs/text/axis.md +0 -20
  167. package/docs/text/context.md +0 -17
  168. package/docs/text/edge.md +0 -16
  169. package/docs/text/latex.md +0 -9
  170. package/docs/text/points.md +0 -11
  171. package/docs/text/triangle.md +0 -5
  172. package/scripts/cli.ts +0 -60
  173. package/scripts/mcp.ts +0 -52
  174. package/src/fonts/IBMPlexMono-Bold.ttf +0 -0
  175. package/src/fonts/NotoColorEmoji-Regular.ttf +0 -0
  176. package/src/fonts/fonts.browser.ts +0 -20
  177. package/src/fonts/fonts.node.ts +0 -17
  178. package/src/lib/math.ts +0 -135
  179. package/src/lib/term.ts +0 -71
  180. /package/docs/code/{axis.jsx → Axis.jsx} +0 -0
  181. /package/docs/code/{box.jsx → Box.jsx} +0 -0
  182. /package/docs/code/{gum.jsx → Gum.jsx} +0 -0
  183. /package/docs/code/{plot.jsx → Plot.jsx} +0 -0
  184. /package/docs/code/{slide.jsx → Slide.jsx} +0 -0
  185. /package/docs/code/{symfill.jsx → SymFill.jsx} +0 -0
  186. /package/docs/code/{symline.jsx → SymLine.jsx} +0 -0
  187. /package/docs/code/{symshape.jsx → SymShape.jsx} +0 -0
  188. /package/docs/code/{textbox.jsx → TextBox.jsx} +0 -0
  189. /package/docs/code/{titleframe.jsx → TitleFrame.jsx} +0 -0
  190. /package/docs/text/{colors.md → Colors.md} +0 -0
  191. /package/docs/text/{ellipse.md → Ellipse.md} +0 -0
  192. /package/docs/text/{graph.md → Graph.md} +0 -0
  193. /package/docs/text/{grid.md → Grid.md} +0 -0
  194. /package/docs/text/{gum.md → Gum.md} +0 -0
  195. /package/docs/text/{plot.md → Plot.md} +0 -0
  196. /package/docs/text/{rect.md → Rect.md} +0 -0
  197. /package/docs/text/{slide.md → Slide.md} +0 -0
  198. /package/docs/text/{symline.md → SymLine.md} +0 -0
  199. /package/docs/text/{symshape.md → SymShape.md} +0 -0
  200. /package/docs/text/{symspline.md → SymSpline.md} +0 -0
  201. /package/docs/text/{textbox.md → TextBox.md} +0 -0
  202. /package/docs/text/{unitline.md → UnitLine.md} +0 -0
  203. /package/{docs/gala → gala/code}/flux_capacitance.jsx +0 -0
  204. /package/{docs/gala → gala/code}/punk_rock.jsx +0 -0
  205. /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.svg" alt="logo" width="500" />
2
+ <img src="image/logo.png" alt="logo" width="500" />
3
3
  <br/>
4
4
  </div>
5
5
 
@@ -38,7 +38,7 @@ const svg = elem.svg()
38
38
 
39
39
  Which will produce the following:
40
40
 
41
- <img src="image/plot.svg" alt="sine wave plot" width="750" />
41
+ <img src="image/plot.png" alt="sine wave plot" width="750" />
42
42
 
43
43
  You can also use JavaScript directly:
44
44
 
@@ -0,0 +1,5 @@
1
+ // elliptical and circular arcs using degree ranges
2
+ <Group>
3
+ <Arc pos={[0.32, 0.5]} size={[0.44, 0.32]} start={-45} end={210} stroke={blue} stroke-width={2} />
4
+ <Arc pos={[0.72, 0.5]} size={0.32} start={90} end={-150} stroke={red} stroke-width={2} />
5
+ </Group>
@@ -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]} rad={0.4}>{e}</Text>
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" size={3} fill={red} />
4
- <Bar label="B" size={8.5} fill={blue} />
5
- <Bar label="C" size={6.5} fill={green} />
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>
@@ -0,0 +1,7 @@
1
+ // the ratio of alpha to beta enclosed in parentheses
2
+ <Bracket>
3
+ <Frac>
4
+ <MathSymbol>\alpha</MathSymbol>
5
+ <MathSymbol>\beta</MathSymbol>
6
+ </Frac>
7
+ </Bracket>
@@ -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.1 * (1+abs(y))/2
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 from="hello" to="world" from-fill={red} to-fill={blue} />
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}>{[pos0, pos1, pos2]}</Shape>
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,5 @@
1
+ // two ellipses, one wider and one taller
2
+ <Group>
3
+ <Ellipse pos={[0.3, 0.2]} size={[0.4, 0.2]} />
4
+ <Ellipse pos={[0.6, 0.6]} size={[0.4, 0.5]} />
5
+ </Group>
@@ -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={0.5} N={100}
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 fill>
5
+ <Frame padding rounded>
6
6
  <Group aspect={1} spin={th}>
7
- <Arrow direc={0} tail={1} pos={[1, 0.5]} rad={0.5} />
7
+ <Arrow points={[[0, 0.5], [1, 0.5]]} arrow-size={0.4} />
8
8
  </Group>
9
9
  </Frame>
10
10
  ) }
@@ -0,0 +1,5 @@
1
+ // a square in the top left and a circle in the bottom right
2
+ <Group>
3
+ <Rectangle pos={[0.3, 0.3]} size={0.2} spin={15} />
4
+ <Ellipse pos={[0.7, 0.7]} size={0.2} />
5
+ </Group>
@@ -0,0 +1,6 @@
1
+ // load "image.png" and display a 2x1 clip from the center
2
+ <Box rounded clip>
3
+ <Group aspect={2}>
4
+ <LoadImage id="image.png" xsize={1} />
5
+ </Group>
6
+ </Box>
@@ -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><Equation>{"\\int_0^{\\infty} \\exp(-x^2) dx = \\sqrt{\\pi}"}</Equation></TextFrame>
4
- <TextFrame><Equation>{"\\sin^2(\\theta) + \\cos^2(\\theta) = 1"}</Equation></TextFrame>
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
- ]}</Line>
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
- ]}</Line>
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-yrad={0.15} node-rounded node-fill={gray} edge-fill={white}>
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 from="hello" to="test" />
7
- <Edge from="hello" to="ball" from-dir="s" curve={3} />
6
+ <Edge start="hello" end="test" />
7
+ <Edge start="hello" end="ball" start-side="s" curve={3} />
8
8
  </Network>
@@ -2,5 +2,5 @@
2
2
  <Network aspect node-fill={gray}>
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 from="hello" to="world" />
5
+ <Edge start="hello" end="world" />
6
6
  </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.02}>{[
3
+ <Points point-size={0.04} points={[
4
4
  [0, 0.5], [0.5, 0], [-0.5, 0], [0, -0.5]
5
- ]}
6
- </Points>
7
- <Rectangle pos={[0.5, 0.5]} rad={0.1} />
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
- <Rectangle pos={[0.25, 0.5]} rad={[0.1, 0.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
- ]}</Shape>
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
- ]}</Shape>
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}>{points}</Spline>
11
- <Shape stroke={red}>{points}</Shape>
12
- <Points size={0.0075}>{points}</Points>
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
- <Rectangle rounded fill={blue} />
4
- <HStack stack-size={0.5} spacing>
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,8 @@
1
+ // x squared with an i subscript
2
+ <TextFrame rounded border={10} fill={gray} margin>
3
+ <MathText>
4
+ <SupSub sup="2" sub="i">
5
+ <MathSymbol>x</MathSymbol>
6
+ </SupSub>
7
+ </MathText>
8
+ </TextFrame>
@@ -1,4 +1,4 @@
1
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} border={2} fill>
3
- <SymField func={(x, y) => 100 * x * y} xlim={[0, 1]} ylim={[0, 1]} N={15} stroke-width={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
4
  </Frame>
@@ -2,5 +2,5 @@
2
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} size={0.125} N={11} shape={x => <Pill spin={-r2d*atan(cos(x))}/>} />
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.05} fill={red} />
9
+ <SymPoints fy={decay} N={10} point-size={0.1} fill={red} />
10
10
  </Plot>
@@ -0,0 +1,6 @@
1
+ // load "data.csv" and plot each row as a blue dot
2
+ return <Graph xlim={[0, 10]} ylim={[0, 10]}>
3
+ {loadTable('data.csv').map(({ x, y }) =>
4
+ <Dot pos={[x, y]} rad={0.1} fill={blue} />
5
+ )}
6
+ </Graph>
@@ -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>
@@ -1,5 +1,5 @@
1
1
  // draw a plus symbol in a frame and place it in the bottom left corner
2
- <Group pos={[0.3, 0.7]} rad={0.2}>
2
+ <Group pos={[0.3, 0.7]} size={0.4}>
3
3
  <VLine />
4
4
  <HLine />
5
5
  </Group>
@@ -0,0 +1,7 @@
1
+ x,y
2
+ 1,2
3
+ 2.5,7.5
4
+ 4,4
5
+ 6,8
6
+ 8,3
7
+ 9,6
Binary file
package/docs/meta.json CHANGED
@@ -1,50 +1,60 @@
1
1
  {
2
2
  "core": [
3
- "gum",
4
- "element",
5
- "group",
6
- "context"
3
+ "Gum",
4
+ "Element",
5
+ "Group"
7
6
  ],
8
7
  "layout": [
9
- "box",
10
- "stack",
11
- "grid",
12
- "points"
13
- ],
14
- "shapes": [
15
- "rect",
16
- "ellipse",
17
- "line",
18
- "shape",
19
- "spline"
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
- "text",
23
- "latex",
24
- "titleframe",
25
- "slide"
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
- "sympoints",
29
- "symline",
30
- "symshape",
31
- "symspline",
32
- "symfill"
36
+ "SymPoints",
37
+ "SymLine",
38
+ "SymShape",
39
+ "SymSpline",
40
+ "SymFill"
33
41
  ],
34
42
  "plotting": [
35
- "graph",
36
- "plot",
37
- "axis",
38
- "barplot"
43
+ "Graph",
44
+ "Plot",
45
+ "Axis",
46
+ "BarPlot"
39
47
  ],
40
48
  "networks": [
41
- "node",
42
- "edge",
43
- "network"
49
+ "Node",
50
+ "Edge",
51
+ "Network"
44
52
  ],
45
53
  "utilities": [
46
- "math",
47
- "arrays",
48
- "colors"
54
+ "Math",
55
+ "Arrays",
56
+ "Colors",
57
+ "Tables",
58
+ "Images"
49
59
  ]
50
60
  }
@@ -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 `size` 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.
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
- - `size` — the height of the bar
11
+ - `value` — the height of the bar
12
12
 
13
13
  Parameters:
14
14
  - `direc` = `v` — the orientation of the bars in the plot
@@ -15,6 +15,7 @@ Parameters:
15
15
  - `margin` = `0` / `0.1` — the margin to be added (outside border)
16
16
  - `border` = `0` / `1` — the border width to use (stroke in pixels)
17
17
  - `rounded` = `0` / `0.1` — the border rounding to use (proportional to the box size)
18
+ - `fill` = `null` — the background color to use (default is no fill)
18
19
  - `adjust` = `true` — whether to adjust values for aspect ratio
19
20
  - `shape` = `Rect` — the shape class to use for the border
20
21
  - `clip` = `false` — whether to clip the contents to the border shape
@@ -0,0 +1,12 @@
1
+ # Bracket
2
+
3
+ *Inherits*: [HStack](/docs/HStack) > [Group](/docs/Group) > [Element](/docs/Element)
4
+
5
+ Wraps a single child in a matched pair of delimiters. The delimiter can be chosen from a preset name or given as a pair to mix left and right shapes.
6
+
7
+ Parameters:
8
+ - `children` — a single element to enclose
9
+ - `delim` = `'round'` — one of `'round'`, `'square'`, `'curly'`, `'angle'`, or a `[left, right]` pair of those values
10
+
11
+ Subunit names:
12
+ - `delim` — forwarded to the generated delimiter symbols, for example `delim-level`
@@ -0,0 +1,16 @@
1
+ # Edge
2
+
3
+ *Inherits*: [Arrow](/docs/Arrow) > [Group](/docs/Group) > [Element](/docs/Element)
4
+
5
+ This creates a cubic spline path from one element (typically a [Node](/docs/Node)) to another with optional arrowheads at either or both ends. It is named **Edge** because of its usage in network diagrams with [Network](/docs/Network). The emanation directions are automatically inferred from the relative node positions but can be overriden as well.
6
+
7
+ Use [Arrow](/docs/Arrow) for creating edges between arbitrary points and for details on options for the path and arrowheads.
8
+
9
+ Parameters:
10
+ - `start`/`end` — the beginning and ending element for the path
11
+ - `start-side`/`end-side` — the attachment side of the arrowheads (cardinal strings)
12
+ - `start-loc`/`end-loc` — the attachment location of the arrowheads (a number between 0 and 1)
13
+ - `points` — the intermediate points to draw the spline between
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` — the arrowhead size to use for both arrows
16
+ - `curve` = `2` — curvature factor forwarded to the spline