File tree Expand file tree Collapse file tree 4 files changed +18
-10
lines changed Expand file tree Collapse file tree 4 files changed +18
-10
lines changed Original file line number Diff line number Diff line change 1111
1212## Examples
1313
14+ ![ Example] ( https://github.com/pemattern/tui-shader/blob/main/assets/pipe-into.gif )
15+
1416For the sake of simplicity, all examples run for a few seconds, and then quit.
1517To run examples use the following command:
1618
Original file line number Diff line number Diff line change 1+ use tui_shader:: ShaderCanvasOptions ;
2+
13pub fn main ( ) -> std:: io:: Result < ( ) > {
24 let mut s = String :: new ( ) ;
35 {
@@ -6,17 +8,20 @@ pub fn main() -> std::io::Result<()> {
68 }
79
810 let mut terminal = ratatui:: init ( ) ;
9- let mut state = tui_shader:: ShaderCanvasState :: new ( "shaders/gradient.wgsl" ) ;
11+ let mut state = tui_shader:: ShaderCanvasState :: new_with_options (
12+ "shaders/gradient.wgsl" ,
13+ ShaderCanvasOptions {
14+ style_rule : tui_shader:: StyleRule :: ColorFg ,
15+ ..Default :: default ( )
16+ } ,
17+ ) ;
1018
1119 let start_time = std:: time:: Instant :: now ( ) ;
12- loop {
20+ while start_time . elapsed ( ) . as_secs ( ) < 7 {
1321 terminal. draw ( |frame| {
1422 frame. render_stateful_widget ( tui_shader:: ShaderCanvas , frame. area ( ) , & mut state) ;
1523 frame. render_widget ( ratatui:: widgets:: Paragraph :: new ( s. as_str ( ) ) , frame. area ( ) ) ;
1624 } ) ?;
17- if start_time. elapsed ( ) . as_secs ( ) > 5 {
18- break ;
19- }
2025 std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 10 ) ) ;
2126 }
2227 ratatui:: restore ( ) ;
Original file line number Diff line number Diff line change 1- Output "assets/stylize-other-widget .gif"
1+ Output "assets/pipe-into .gif"
22Set FontFamily "JetBrainsMonoNL NF"
3- Set Width 400
3+ Set Width 880
44Set Height 200
5+ Type@50ms `echo "fancy..." | cargo run --example=pipe-into`
6+ Sleep 1s
57Hide
6- Type "cargo run --example=stylize-other-widget"
78Enter
8- Sleep 2s
9+ Sleep 1s
910Show
10- Sleep 6.4s
11+ Sleep 5s
You can’t perform that action at this time.
0 commit comments