Skip to content

Commit ad2dc56

Browse files
authored
docs(examples): update examples readme (#576)
remove VHS bug info, tweak colors_rgb image, update some of the instructions. add demo2
1 parent 6cbdb06 commit ad2dc56

File tree

3 files changed

+30
-27
lines changed

3 files changed

+30
-27
lines changed

examples/README.md

+21-22
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
# Examples
22

3-
These gifs were created using [Charm VHS](https://github.com/charmbracelet/vhs).
3+
These gifs were created using [VHS](https://github.com/charmbracelet/vhs). Each example has a
4+
corresponding `.tape` file that holds instructions for how to generate the images. Note that the
5+
images themselves are stored in a separate git branch to avoid bloating the main repository.
46

5-
VHS has a problem rendering some background color transitions, which shows up in several examples
6-
below. See <https://github.com/charmbracelet/vhs/issues/344> for more info. These problems don't
7-
occur in a terminal.
7+
## Demo2
8+
9+
This is the demo example from the main README and crate page. Source: [demo2](./demo2/).
10+
11+
```shell
12+
cargo run --example=demo2 --features=crossterm
13+
```
14+
15+
![Demo2][demo2.gif]
816

917
## Demo
1018

@@ -102,19 +110,20 @@ cargo run --example=colors --features=crossterm
102110

103111
Demonstrates the available RGB
104112
[`Color`](https://docs.rs/ratatui/latest/ratatui/style/enum.Color.html) options. These can be used
105-
in any style field. Source: [colors_rgb.rs](./colors_rgb.rs).
113+
in any style field. Source: [colors_rgb.rs](./colors_rgb.rs). Uses a half block technique to render
114+
two square-ish pixels in the space of a single rectangular terminal cell.
106115

107116
```shell
108117
cargo run --example=colors_rgb --features=crossterm
109118
```
110119

111-
![Colors RGB][colors_rgb.gif]
120+
![Colors RGB][colors_rgb.png]
112121

113122
## Custom Widget
114123

115124
Demonstrates how to implement the
116-
[`Widget`](https://docs.rs/ratatui/latest/ratatui/widgets/trait.Widget.html) trait. Source:
117-
[custom_widget.rs](./custom_widget.rs).
125+
[`Widget`](https://docs.rs/ratatui/latest/ratatui/widgets/trait.Widget.html) trait. Also shows mouse
126+
interaction. Source: [custom_widget.rs](./custom_widget.rs).
118127

119128
```shell
120129
cargo run --example=custom_widget --features=crossterm
@@ -127,10 +136,6 @@ cargo run --example=custom_widget --features=crossterm
127136
Demonstrates the [`Gauge`](https://docs.rs/ratatui/latest/ratatui/widgets/struct.Gauge.html) widget.
128137
Source: [gauge.rs](./gauge.rs).
129138

130-
> [!NOTE] The backgrounds render poorly when we generate this example using VHS. This problem
131-
> doesn't generally happen during normal rendering in a terminal. See
132-
> [vhs#344](https://github.com/charmbracelet/vhs/issues/344) for more details.
133-
134139
```shell
135140
cargo run --example=gauge --features=crossterm
136141
```
@@ -139,7 +144,7 @@ cargo run --example=gauge --features=crossterm
139144

140145
## Inline
141146

142-
Demonstrates the
147+
Demonstrates how to use the
143148
[`Inline`](https://docs.rs/ratatui/latest/ratatui/terminal/enum.Viewport.html#variant.Inline)
144149
Viewport mode for ratatui apps. Source: [inline.rs](./inline.rs).
145150

@@ -216,10 +221,6 @@ Demonstrates how to render a widget over the top of previously rendered widgets
216221
cargo run --example=popup --features=crossterm
217222
```
218223

219-
> [!NOTE] The background renders poorly after the popup when we generate this example using VHS.
220-
> This problem doesn't generally happen during normal rendering in a terminal. See
221-
> [vhs#344](https://github.com/charmbracelet/vhs/issues/344) for more details.
222-
223224
![Popup][popup.gif]
224225

225226
## Scrollbar
@@ -238,10 +239,6 @@ cargo run --example=scrollbar --features=crossterm
238239
Demonstrates the [`Sparkline`](https://docs.rs/ratatui/latest/ratatui/widgets/struct.Sparkline.html)
239240
widget. Source: [sparkline.rs](./sparkline.rs).
240241

241-
> [!NOTE] The background renders poorly in the second sparkline when we generate this example using
242-
> VHS. This problem doesn't generally happen during normal rendering in a terminal. See
243-
> [vhs#344](https://github.com/charmbracelet/vhs/issues/344) for more details.
244-
245242
```shell
246243
cargo run --example=sparkline --features=crossterm
247244
```
@@ -292,15 +289,17 @@ To update these examples in bulk:
292289
examples/generate.bash
293290
```
294291
-->
292+
295293
[barchart.gif]: https://github.com/ratatui-org/ratatui/blob/images/examples/barchart.gif?raw=true
296294
[block.gif]: https://github.com/ratatui-org/ratatui/blob/images/examples/block.gif?raw=true
297295
[calendar.gif]: https://github.com/ratatui-org/ratatui/blob/images/examples/calendar.gif?raw=true
298296
[canvas.gif]: https://github.com/ratatui-org/ratatui/blob/images/examples/canvas.gif?raw=true
299297
[chart.gif]: https://github.com/ratatui-org/ratatui/blob/images/examples/chart.gif?raw=true
300298
[colors.gif]: https://github.com/ratatui-org/ratatui/blob/images/examples/colors.gif?raw=true
301-
[colors_rgb.gif]: https://github.com/ratatui-org/ratatui/blob/images/examples/colors_rgb.gif?raw=true
299+
[colors_rgb.png]: https://github.com/ratatui-org/ratatui/blob/images/examples/colors_rgb.png?raw=true
302300
[custom_widget.gif]: https://github.com/ratatui-org/ratatui/blob/images/examples/custom_widget.gif?raw=true
303301
[demo.gif]: https://github.com/ratatui-org/ratatui/blob/images/examples/demo.gif?raw=true
302+
[demo2.gif]: https://github.com/ratatui-org/ratatui/blob/images/examples/demo2.gif?raw=true
304303
[gauge.gif]: https://github.com/ratatui-org/ratatui/blob/images/examples/gauge.gif?raw=true
305304
[hello_world.gif]: https://github.com/ratatui-org/ratatui/blob/images/examples/hello_world.gif?raw=true
306305
[inline.gif]: https://github.com/ratatui-org/ratatui/blob/images/examples/inline.gif?raw=true

examples/colors_rgb.tape

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
Output "target/colors_rgb.gif"
44
Set Theme "Aardvark Blue"
55
Set Width 1200
6-
Set Height 1410
6+
Set Height 800
77
Hide
88
Type "cargo run --example=colors_rgb --features=crossterm"
99
Enter
1010
Sleep 2s
11+
Screenshot "target/colors_rgb.png"
1112
Show
1213
Sleep 1s

examples/generate.bash

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
# - cargo: https://doc.rust-lang.org/cargo/getting-started/installation.html
66
# - gh: https://github.com/cli/cli
77
# - git: https://git-scm.com/
8-
# - vhs: https://github.com/charmbracelet/vhs
8+
# - vhs: https://github.com/charmbracelet/vhs - currently this needs to be installed from the
9+
# main branch, as the latest release doesn't support the theme we use or the Screenshot
10+
# command. Install using `go install github.com/charmbracelet/vhs@main``
11+
# - go: https://golang.org/doc/install
12+
# - ttyd: https://github.com/tsl0922/ttyd
913

1014
# Exit on error. Append "|| true" if you expect an error.
1115
set -o errexit
@@ -21,9 +25,8 @@ set -o pipefail
2125
# ensure that running each example doesn't have to wait for the build
2226
cargo build --examples --features=crossterm,all-widgets
2327

24-
for tape in examples/*.tape
25-
do
26-
gif=${tape/examples\/}
28+
for tape in examples/*.tape; do
29+
gif=${tape/examples\//}
2730
gif=${gif/.tape/.gif}
2831
~/go/bin/vhs $tape --quiet
2932
# this can be pasted into the examples README.md

0 commit comments

Comments
 (0)