Skip to content

Commit c267789

Browse files
committed
chore: updated demo
1 parent c465930 commit c267789

File tree

7 files changed

+99
-4
lines changed

7 files changed

+99
-4
lines changed

Cargo.lock

Lines changed: 61 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ ratatui = "0.29.0"
2323

2424
[dev-dependencies]
2525
rand = "0.9.0"
26+
tui-big-text = "0.7.1"
2627

2728
[[example]]
2829
name = "demo"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![Header](https://github.com/pemattern/tui-shader/blob/main/assets/stylize-other-widget.gif)
1+
![Header](https://github.com/pemattern/tui-shader/blob/main/assets/demo.gif)
22

33
## What is tui-shader?
44

assets/demo.gif

2.14 MB
Loading

examples/demo/demo.tape

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Output "assets/demo.gif"
2+
Set Margin 0
3+
Set Padding 0
4+
Set PlaybackSpeed 1
5+
Set FontFamily "JetBrainsMonoNL NF"
6+
Set FontSize 9
7+
Set Width 720
8+
Set Height 400
9+
Hide
10+
Type "cargo run --example=demo"
11+
Enter
12+
Sleep 1s
13+
Show
14+
Sleep 12s

examples/demo/main.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,38 @@
1+
use ratatui::style::Stylize;
2+
3+
const DARK_COLOR: ratatui::style::Color = ratatui::style::Color::Rgb(75, 71, 92);
4+
const LIGHT_COLOR: ratatui::style::Color = ratatui::style::Color::Rgb(215, 222, 220);
5+
16
fn main() {
27
let mut terminal = ratatui::init();
38
let mut state = tui_shader::ShaderCanvasState::new_with_options(
49
"shaders/dither.wgsl",
510
tui_shader::ShaderCanvasOptions {
11+
style_rule: tui_shader::StyleRule::Map(|sample| {
12+
if sample.r() > 127 {
13+
ratatui::style::Style::new().fg(DARK_COLOR).bg(LIGHT_COLOR)
14+
} else {
15+
ratatui::style::Style::new().fg(LIGHT_COLOR).bg(DARK_COLOR)
16+
}
17+
}),
618
..Default::default()
719
},
820
);
921

1022
let start_time = std::time::Instant::now();
23+
// run at 128x32 cells
1124
while start_time.elapsed().as_secs() < 20 {
1225
terminal
1326
.draw(|frame| {
1427
frame.render_stateful_widget(tui_shader::ShaderCanvas, frame.area(), &mut state);
28+
frame.render_widget(
29+
tui_big_text::BigText::builder()
30+
.pixel_size(tui_big_text::PixelSize::Full)
31+
.lines(vec!["tui-shader".into()])
32+
.centered()
33+
.build(),
34+
frame.area().inner(ratatui::layout::Margin::new(4, 12)),
35+
);
1536
})
1637
.unwrap();
1738
std::thread::sleep(std::time::Duration::from_millis(20));

shaders/dither.wgsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ const BAYER_8X8: array<array<f32, 8>, 8> = array(
123123
array(0.984375, 0.484375, 0.953125, 0.453125, 0.828125, 0.328125, 0.859375, 0.359375),
124124
);
125125

126-
const margin: f32 = 0.2;
126+
const margin: f32 = 0.15;
127127
const dark_color = vec4<f32>(0.294, 0.278, 0.361, 1.0);
128128
const light_color = vec4<f32>(0.843, 0.871, 0.863, 1.0);
129129

0 commit comments

Comments
 (0)