pub struct GradientBlock<'a> {
pub fill: Line<'a>,
pub titles: Vec<T<'a>>,
pub bg: Option<Color>,
pub border_segments: BorderSegments,
}Expand description
A struct that represents a customizable block with gradient text, borders, and other visual elements.
This struct allows you to create and manage blocks that have a gradient color effect for text, customizable borders, and areas with specific alignments and fill styles.
Fields§
§fill: Line<'a>§titles: Vec<T<'a>>§bg: Option<Color>§border_segments: BorderSegmentsImplementations§
Source§impl GradientBlock<'_>
impl GradientBlock<'_>
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
24fn run(
25 terminal: &mut ratatui::DefaultTerminal,
26 set: SegmentSet,
27) -> io::Result<()> {
28 use tui_gradient_block::gradient_block::GradientBlock;
29 let block = GradientBlock::new()
30 .with_set(set)
31 .left_gradient(solid((48, 174, 209)))
32 .bottom_gradient(solid((48, 174, 209)))
33 .top_gradient(Box::new(
34 GradientBuilder::new()
35 .colors(&[
36 Color::from_rgba8(48, 174, 209, 1),
37 Color::from_rgba8(225, 22, 247, 1),
38 ])
39 .build::<colorgrad::LinearGradient>()
40 .unwrap(),
41 ))
42 .right_gradient(Box::new(
43 GradientBuilder::new()
44 .colors(&[
45 Color::from_rgba8(225, 22, 247, 1),
46 Color::from_rgba8(48, 174, 209, 1),
47 ])
48 .build::<colorgrad::LinearGradient>()
49 .unwrap(),
50 ));
51
52 loop {
53 terminal.draw(|f| f.render_widget(&block, f.area()))?;
54 let event = event::read()?;
55
56 if let Event::Key(key_event) = event {
57 if key_event.kind == KeyEventKind::Press {
58 if let KeyCode::Char('q') = key_event.code {
59 break Ok(());
60 }
61 }
62 }
63 }
64}More examples
15fn run(
16 terminal: &mut ratatui::DefaultTerminal,
17 set: SegmentSet,
18) -> io::Result<()> {
19 use ratatui::{text::Line, layout::{Constraint, Direction, Layout}};
20 use tui_gradient_block::{
21 gradient_block::GradientBlock,
22 theme_presets::cool::t_zombie_dreams,
23 };
24 let theme = t_zombie_dreams::full();
25 let blocks = vec![
26 GradientBlock::new()
27 .with_gradient(theme.double_corners_left)
28 .with_set(set.clone()),
29 GradientBlock::new().title_top(Line::from(tui_rule::generate_gradient_text!("Zombie Dreams", theme.right.top)).centered())
30 .with_gradient(theme.misc1)
31 .with_set(set.clone()),
32 GradientBlock::new()
33 .with_gradient(theme.double_corners_right)
34 .with_set(set.clone()),
35 ];
36
37 loop {
38 terminal.draw(|f| {
39 let base = Layout::new(
40 Direction::Horizontal,
41 [
42 Constraint::Percentage(33),
43 Constraint::Percentage(33),
44 Constraint::Percentage(34),
45 ],
46 )
47 .vertical_margin(1)
48 .horizontal_margin(1)
49 .spacing(3)
50 .split(f.area());
51 for (block, area) in blocks.iter().zip(base.iter()) {
52 f.render_widget(block, *area);
53 }
54 })?;
55 let event = event::read()?;
56
57 if let Event::Key(key_event) = event {
58 if key_event.kind == KeyEventKind::Press {
59 if let KeyCode::Char('q') = key_event.code {
60 break Ok(());
61 }
62 }
63 }
64 }
65}14fn run(
15 terminal: &mut ratatui::DefaultTerminal,
16 set: SegmentSet,
17) -> io::Result<()> {
18 use ratatui::layout::{Constraint, Direction, Layout};
19 use tui_gradient_block::{
20 gradient_block::GradientBlock,
21 theme_presets::cool::t_misty_blue,
22 };
23 let titles = t_misty_blue::titles();
24 let theme = t_misty_blue::full();
25 let blocks_top = vec![
26 GradientBlock::new()
27 .title(titles.up.0, titles.up.1)
28 .with_gradient(theme.up)
29 .with_set(set.clone()),
30 GradientBlock::new()
31 .title(titles.down.0, titles.down.1)
32 .with_gradient(theme.down)
33 .with_set(set.clone()),
34 GradientBlock::new()
35 .title(titles.left.0, titles.left.1)
36 .with_gradient(theme.left)
37 .with_set(set.clone()),
38 GradientBlock::new()
39 .title(titles.right.0, titles.right.1)
40 .with_gradient(theme.right)
41 .with_set(set.clone()),
42 GradientBlock::new()
43 .title(titles.top_left.0, titles.top_left.1)
44 .with_gradient(theme.top_left)
45 .with_set(set.clone()),
46 GradientBlock::new()
47 .title(titles.top_right.0, titles.top_right.1)
48 .with_gradient(theme.top_right)
49 .with_set(set.clone()),
50 GradientBlock::new()
51 .title(titles.bottom_left.0, titles.bottom_left.1)
52 .with_gradient(theme.bottom_left)
53 .with_set(set.clone()),
54 ];
55 let blocks_bottom = vec![
56 GradientBlock::new()
57 .title(titles.bottom_right.0, titles.bottom_right.1)
58 .with_gradient(theme.bottom_right)
59 .with_set(set.clone()),
60 GradientBlock::new()
61 .title(
62 titles.double_corners_left.0,
63 titles.double_corners_left.1,
64 )
65 .with_gradient(theme.double_corners_left)
66 .with_set(set.clone()),
67 GradientBlock::new()
68 .title(
69 titles.double_corners_right.0,
70 titles.double_corners_right.1,
71 )
72 .with_gradient(theme.double_corners_right)
73 .with_set(set.clone()),
74 GradientBlock::new()
75 .title(titles.vertical.0, titles.vertical.1)
76 .with_gradient(theme.vertical)
77 .with_set(set.clone()),
78 GradientBlock::new()
79 .title(titles.horizontal.0, titles.horizontal.1)
80 .with_gradient(theme.horizontal)
81 .with_set(set.clone()),
82 GradientBlock::new()
83 .title(titles.misc1.0, titles.misc1.1)
84 .with_gradient(theme.misc1)
85 .with_set(set.clone()),
86 GradientBlock::new()
87 .title(titles.misc2.0, titles.misc2.1)
88 .with_gradient(theme.misc2)
89 .with_set(set.clone()),
90 ];
91
92 loop {
93 terminal.draw(|f| {
94 let base = Layout::new(
95 Direction::Vertical,
96 [
97 Constraint::Percentage(50),
98 Constraint::Percentage(50),
99 ],
100 )
101 .split(f.area());
102 let top = Layout::new(
103 Direction::Horizontal,
104 [
105 Constraint::Percentage(14),
106 Constraint::Percentage(14),
107 Constraint::Percentage(14),
108 Constraint::Percentage(14),
109 Constraint::Percentage(14),
110 Constraint::Percentage(15),
111 Constraint::Percentage(15),
112 ],
113 )
114 .split(base[0]);
115 let bottom = Layout::new(
116 Direction::Horizontal,
117 [
118 Constraint::Percentage(14),
119 Constraint::Percentage(14),
120 Constraint::Percentage(14),
121 Constraint::Percentage(14),
122 Constraint::Percentage(14),
123 Constraint::Percentage(15),
124 Constraint::Percentage(15),
125 ],
126 )
127 .split(base[1]);
128 for (block, area) in blocks_top.iter().zip(top.iter()) {
129 f.render_widget(block, *area);
130 }
131 for (block, area) in
132 blocks_bottom.iter().zip(bottom.iter())
133 {
134 f.render_widget(block, *area);
135 }
136 })?;
137 let event = event::read()?;
138
139 if let Event::Key(key_event) = event {
140 if key_event.kind == KeyEventKind::Press {
141 if let KeyCode::Char('q') = key_event.code {
142 break Ok(());
143 }
144 }
145 }
146 }
147}14fn run(
15 terminal: &mut ratatui::DefaultTerminal,
16 set: SegmentSet,
17) -> io::Result<()> {
18 use ratatui::layout::{Constraint, Direction, Layout};
19 use tui_gradient_block::{
20 gradient_block::GradientBlock,
21 theme_presets::misc::t_monochrome,
22 };
23 let titles = t_monochrome::titles();
24 let theme = t_monochrome::full();
25 let blocks_top = vec![
26 GradientBlock::new()
27 .title(titles.up.0, titles.up.1)
28 .with_gradient(theme.up)
29 .with_set(set.clone()),
30 GradientBlock::new()
31 .title(titles.down.0, titles.down.1)
32 .with_gradient(theme.down)
33 .with_set(set.clone()),
34 GradientBlock::new()
35 .title(titles.left.0, titles.left.1)
36 .with_gradient(theme.left)
37 .with_set(set.clone()),
38 GradientBlock::new()
39 .title(titles.right.0, titles.right.1)
40 .with_gradient(theme.right)
41 .with_set(set.clone()),
42 GradientBlock::new()
43 .title(titles.top_left.0, titles.top_left.1)
44 .with_gradient(theme.top_left)
45 .with_set(set.clone()),
46 GradientBlock::new()
47 .title(titles.top_right.0, titles.top_right.1)
48 .with_gradient(theme.top_right)
49 .with_set(set.clone()),
50 GradientBlock::new()
51 .title(titles.bottom_left.0, titles.bottom_left.1)
52 .with_gradient(theme.bottom_left)
53 .with_set(set.clone()),
54 ];
55 let blocks_bottom = vec![
56 GradientBlock::new()
57 .title(titles.bottom_right.0, titles.bottom_right.1)
58 .with_gradient(theme.bottom_right)
59 .with_set(set.clone()),
60 GradientBlock::new()
61 .title(
62 titles.double_corners_left.0,
63 titles.double_corners_left.1,
64 )
65 .with_gradient(theme.double_corners_left)
66 .with_set(set.clone()),
67 GradientBlock::new()
68 .title(
69 titles.double_corners_right.0,
70 titles.double_corners_right.1,
71 )
72 .with_gradient(theme.double_corners_right)
73 .with_set(set.clone()),
74 GradientBlock::new()
75 .title(titles.vertical.0, titles.vertical.1)
76 .with_gradient(theme.vertical)
77 .with_set(set.clone()),
78 GradientBlock::new()
79 .title(titles.horizontal.0, titles.horizontal.1)
80 .with_gradient(theme.horizontal)
81 .with_set(set.clone()),
82 GradientBlock::new()
83 .title(titles.misc1.0, titles.misc1.1)
84 .with_gradient(theme.misc1)
85 .with_set(set.clone()),
86 GradientBlock::new()
87 .title(titles.misc2.0, titles.misc2.1)
88 .with_gradient(theme.misc2)
89 .with_set(set.clone()),
90 ];
91
92 loop {
93 terminal.draw(|f| {
94 let base = Layout::new(
95 Direction::Vertical,
96 [
97 Constraint::Percentage(50),
98 Constraint::Percentage(50),
99 ],
100 )
101 .split(f.area());
102 let top = Layout::new(
103 Direction::Horizontal,
104 [
105 Constraint::Percentage(14),
106 Constraint::Percentage(14),
107 Constraint::Percentage(14),
108 Constraint::Percentage(14),
109 Constraint::Percentage(14),
110 Constraint::Percentage(15),
111 Constraint::Percentage(15),
112 ],
113 )
114 .split(base[0]);
115 let bottom = Layout::new(
116 Direction::Horizontal,
117 [
118 Constraint::Percentage(14),
119 Constraint::Percentage(14),
120 Constraint::Percentage(14),
121 Constraint::Percentage(14),
122 Constraint::Percentage(14),
123 Constraint::Percentage(15),
124 Constraint::Percentage(15),
125 ],
126 )
127 .split(base[1]);
128 for (block, area) in blocks_top.iter().zip(top.iter()) {
129 f.render_widget(block, *area);
130 }
131 for (block, area) in
132 blocks_bottom.iter().zip(bottom.iter())
133 {
134 f.render_widget(block, *area);
135 }
136 })?;
137 let event = event::read()?;
138
139 if let Event::Key(key_event) = event {
140 if key_event.kind == KeyEventKind::Press {
141 if let KeyCode::Char('q') = key_event.code {
142 break Ok(());
143 }
144 }
145 }
146 }
147}14fn run(
15 terminal: &mut ratatui::DefaultTerminal,
16 set: SegmentSet,
17) -> io::Result<()> {
18 use ratatui::layout::{Constraint, Direction, Layout};
19 use tui_gradient_block::{
20 gradient_block::GradientBlock,
21 theme_presets::cool::t_minty_green,
22 };
23 let titles = t_minty_green::titles();
24 let theme = t_minty_green::full();
25 let blocks_top = vec![
26 GradientBlock::new()
27 .title(titles.up.0, titles.up.1)
28 .with_gradient(theme.up)
29 .with_set(set.clone()),
30 GradientBlock::new()
31 .title(titles.down.0, titles.down.1)
32 .with_gradient(theme.down)
33 .with_set(set.clone()),
34 GradientBlock::new()
35 .title(titles.left.0, titles.left.1)
36 .with_gradient(theme.left)
37 .with_set(set.clone()),
38 GradientBlock::new()
39 .title(titles.right.0, titles.right.1)
40 .with_gradient(theme.right)
41 .with_set(set.clone()),
42 GradientBlock::new()
43 .title(titles.top_left.0, titles.top_left.1)
44 .with_gradient(theme.top_left)
45 .with_set(set.clone()),
46 GradientBlock::new()
47 .title(titles.top_right.0, titles.top_right.1)
48 .with_gradient(theme.top_right)
49 .with_set(set.clone()),
50 GradientBlock::new()
51 .title(titles.bottom_left.0, titles.bottom_left.1)
52 .with_gradient(theme.bottom_left)
53 .with_set(set.clone()),
54 ];
55 let blocks_bottom = vec![
56 GradientBlock::new()
57 .title(titles.bottom_right.0, titles.bottom_right.1)
58 .with_gradient(theme.bottom_right)
59 .with_set(set.clone()),
60 GradientBlock::new()
61 .title(
62 titles.double_corners_left.0,
63 titles.double_corners_left.1,
64 )
65 .with_gradient(theme.double_corners_left)
66 .with_set(set.clone()),
67 GradientBlock::new()
68 .title(
69 titles.double_corners_right.0,
70 titles.double_corners_right.1,
71 )
72 .with_gradient(theme.double_corners_right)
73 .with_set(set.clone()),
74 GradientBlock::new()
75 .title(titles.vertical.0, titles.vertical.1)
76 .with_gradient(theme.vertical)
77 .with_set(set.clone()),
78 GradientBlock::new()
79 .title(titles.horizontal.0, titles.horizontal.1)
80 .with_gradient(theme.horizontal)
81 .with_set(set.clone()),
82 GradientBlock::new()
83 .title(titles.misc1.0, titles.misc1.1)
84 .with_gradient(theme.misc1)
85 .with_set(set.clone()),
86 GradientBlock::new()
87 .title(titles.misc2.0, titles.misc2.1)
88 .with_gradient(theme.misc2)
89 .with_set(set.clone()),
90 ];
91
92 loop {
93 terminal.draw(|f| {
94 let base = Layout::new(
95 Direction::Vertical,
96 [
97 Constraint::Percentage(50),
98 Constraint::Percentage(50),
99 ],
100 )
101 .split(f.area());
102 let top = Layout::new(
103 Direction::Horizontal,
104 [
105 Constraint::Percentage(14),
106 Constraint::Percentage(14),
107 Constraint::Percentage(14),
108 Constraint::Percentage(14),
109 Constraint::Percentage(14),
110 Constraint::Percentage(15),
111 Constraint::Percentage(15),
112 ],
113 )
114 .split(base[0]);
115 let bottom = Layout::new(
116 Direction::Horizontal,
117 [
118 Constraint::Percentage(14),
119 Constraint::Percentage(14),
120 Constraint::Percentage(14),
121 Constraint::Percentage(14),
122 Constraint::Percentage(14),
123 Constraint::Percentage(15),
124 Constraint::Percentage(15),
125 ],
126 )
127 .split(base[1]);
128 for (block, area) in blocks_top.iter().zip(top.iter()) {
129 f.render_widget(block, *area);
130 }
131 for (block, area) in
132 blocks_bottom.iter().zip(bottom.iter())
133 {
134 f.render_widget(block, *area);
135 }
136 })?;
137 let event = event::read()?;
138
139 if let Event::Key(key_event) = event {
140 if key_event.kind == KeyEventKind::Press {
141 if let KeyCode::Char('q') = key_event.code {
142 break Ok(());
143 }
144 }
145 }
146 }
147}14fn run(
15 terminal: &mut ratatui::DefaultTerminal,
16 set: SegmentSet,
17) -> io::Result<()> {
18 use ratatui::layout::{Constraint, Direction, Layout};
19 use tui_gradient_block::{
20 gradient_block::GradientBlock,
21 theme_presets::warm::t_rusty_ruins,
22 };
23 let titles = t_rusty_ruins::titles();
24 let theme = t_rusty_ruins::full();
25 let blocks_top = vec![
26 GradientBlock::new()
27 .title(titles.up.0, titles.up.1)
28 .with_gradient(theme.up)
29 .with_set(set.clone()),
30 GradientBlock::new()
31 .title(titles.down.0, titles.down.1)
32 .with_gradient(theme.down)
33 .with_set(set.clone()),
34 GradientBlock::new()
35 .title(titles.left.0, titles.left.1)
36 .with_gradient(theme.left)
37 .with_set(set.clone()),
38 GradientBlock::new()
39 .title(titles.right.0, titles.right.1)
40 .with_gradient(theme.right)
41 .with_set(set.clone()),
42 GradientBlock::new()
43 .title(titles.top_left.0, titles.top_left.1)
44 .with_gradient(theme.top_left)
45 .with_set(set.clone()),
46 GradientBlock::new()
47 .title(titles.top_right.0, titles.top_right.1)
48 .with_gradient(theme.top_right)
49 .with_set(set.clone()),
50 GradientBlock::new()
51 .title(titles.bottom_left.0, titles.bottom_left.1)
52 .with_gradient(theme.bottom_left)
53 .with_set(set.clone()),
54 ];
55 let blocks_bottom = vec![
56 GradientBlock::new()
57 .title(titles.bottom_right.0, titles.bottom_right.1)
58 .with_gradient(theme.bottom_right)
59 .with_set(set.clone()),
60 GradientBlock::new()
61 .title(
62 titles.double_corners_left.0,
63 titles.double_corners_left.1,
64 )
65 .with_gradient(theme.double_corners_left)
66 .with_set(set.clone()),
67 GradientBlock::new()
68 .title(
69 titles.double_corners_right.0,
70 titles.double_corners_right.1,
71 )
72 .with_gradient(theme.double_corners_right)
73 .with_set(set.clone()),
74 GradientBlock::new()
75 .title(titles.vertical.0, titles.vertical.1)
76 .with_gradient(theme.vertical)
77 .with_set(set.clone()),
78 GradientBlock::new()
79 .title(titles.horizontal.0, titles.horizontal.1)
80 .with_gradient(theme.horizontal)
81 .with_set(set.clone()),
82 GradientBlock::new()
83 .title(titles.misc1.0, titles.misc1.1)
84 .with_gradient(theme.misc1)
85 .with_set(set.clone()),
86 GradientBlock::new()
87 .title(titles.misc2.0, titles.misc2.1)
88 .with_gradient(theme.misc2)
89 .with_set(set.clone()),
90 ];
91
92 loop {
93 terminal.draw(|f| {
94 let base = Layout::new(
95 Direction::Vertical,
96 [
97 Constraint::Percentage(50),
98 Constraint::Percentage(50),
99 ],
100 )
101 .split(f.area());
102 let top = Layout::new(
103 Direction::Horizontal,
104 [
105 Constraint::Percentage(14),
106 Constraint::Percentage(14),
107 Constraint::Percentage(14),
108 Constraint::Percentage(14),
109 Constraint::Percentage(14),
110 Constraint::Percentage(15),
111 Constraint::Percentage(15),
112 ],
113 )
114 .split(base[0]);
115 let bottom = Layout::new(
116 Direction::Horizontal,
117 [
118 Constraint::Percentage(14),
119 Constraint::Percentage(14),
120 Constraint::Percentage(14),
121 Constraint::Percentage(14),
122 Constraint::Percentage(14),
123 Constraint::Percentage(15),
124 Constraint::Percentage(15),
125 ],
126 )
127 .split(base[1]);
128 for (block, area) in blocks_top.iter().zip(top.iter()) {
129 f.render_widget(block, *area);
130 }
131 for (block, area) in
132 blocks_bottom.iter().zip(bottom.iter())
133 {
134 f.render_widget(block, *area);
135 }
136 })?;
137 let event = event::read()?;
138
139 if let Event::Key(key_event) = event {
140 if key_event.kind == KeyEventKind::Press {
141 if let KeyCode::Char('q') = key_event.code {
142 break Ok(());
143 }
144 }
145 }
146 }
147}Source§impl<'a> GradientBlock<'a>
impl<'a> GradientBlock<'a>
Sourcepub fn with_gradient(self, gradient: GradientVariation) -> Self
pub fn with_gradient(self, gradient: GradientVariation) -> Self
Examples found in repository?
15fn run(
16 terminal: &mut ratatui::DefaultTerminal,
17 set: SegmentSet,
18) -> io::Result<()> {
19 use ratatui::{text::Line, layout::{Constraint, Direction, Layout}};
20 use tui_gradient_block::{
21 gradient_block::GradientBlock,
22 theme_presets::cool::t_zombie_dreams,
23 };
24 let theme = t_zombie_dreams::full();
25 let blocks = vec![
26 GradientBlock::new()
27 .with_gradient(theme.double_corners_left)
28 .with_set(set.clone()),
29 GradientBlock::new().title_top(Line::from(tui_rule::generate_gradient_text!("Zombie Dreams", theme.right.top)).centered())
30 .with_gradient(theme.misc1)
31 .with_set(set.clone()),
32 GradientBlock::new()
33 .with_gradient(theme.double_corners_right)
34 .with_set(set.clone()),
35 ];
36
37 loop {
38 terminal.draw(|f| {
39 let base = Layout::new(
40 Direction::Horizontal,
41 [
42 Constraint::Percentage(33),
43 Constraint::Percentage(33),
44 Constraint::Percentage(34),
45 ],
46 )
47 .vertical_margin(1)
48 .horizontal_margin(1)
49 .spacing(3)
50 .split(f.area());
51 for (block, area) in blocks.iter().zip(base.iter()) {
52 f.render_widget(block, *area);
53 }
54 })?;
55 let event = event::read()?;
56
57 if let Event::Key(key_event) = event {
58 if key_event.kind == KeyEventKind::Press {
59 if let KeyCode::Char('q') = key_event.code {
60 break Ok(());
61 }
62 }
63 }
64 }
65}More examples
14fn run(
15 terminal: &mut ratatui::DefaultTerminal,
16 set: SegmentSet,
17) -> io::Result<()> {
18 use ratatui::layout::{Constraint, Direction, Layout};
19 use tui_gradient_block::{
20 gradient_block::GradientBlock,
21 theme_presets::cool::t_misty_blue,
22 };
23 let titles = t_misty_blue::titles();
24 let theme = t_misty_blue::full();
25 let blocks_top = vec![
26 GradientBlock::new()
27 .title(titles.up.0, titles.up.1)
28 .with_gradient(theme.up)
29 .with_set(set.clone()),
30 GradientBlock::new()
31 .title(titles.down.0, titles.down.1)
32 .with_gradient(theme.down)
33 .with_set(set.clone()),
34 GradientBlock::new()
35 .title(titles.left.0, titles.left.1)
36 .with_gradient(theme.left)
37 .with_set(set.clone()),
38 GradientBlock::new()
39 .title(titles.right.0, titles.right.1)
40 .with_gradient(theme.right)
41 .with_set(set.clone()),
42 GradientBlock::new()
43 .title(titles.top_left.0, titles.top_left.1)
44 .with_gradient(theme.top_left)
45 .with_set(set.clone()),
46 GradientBlock::new()
47 .title(titles.top_right.0, titles.top_right.1)
48 .with_gradient(theme.top_right)
49 .with_set(set.clone()),
50 GradientBlock::new()
51 .title(titles.bottom_left.0, titles.bottom_left.1)
52 .with_gradient(theme.bottom_left)
53 .with_set(set.clone()),
54 ];
55 let blocks_bottom = vec![
56 GradientBlock::new()
57 .title(titles.bottom_right.0, titles.bottom_right.1)
58 .with_gradient(theme.bottom_right)
59 .with_set(set.clone()),
60 GradientBlock::new()
61 .title(
62 titles.double_corners_left.0,
63 titles.double_corners_left.1,
64 )
65 .with_gradient(theme.double_corners_left)
66 .with_set(set.clone()),
67 GradientBlock::new()
68 .title(
69 titles.double_corners_right.0,
70 titles.double_corners_right.1,
71 )
72 .with_gradient(theme.double_corners_right)
73 .with_set(set.clone()),
74 GradientBlock::new()
75 .title(titles.vertical.0, titles.vertical.1)
76 .with_gradient(theme.vertical)
77 .with_set(set.clone()),
78 GradientBlock::new()
79 .title(titles.horizontal.0, titles.horizontal.1)
80 .with_gradient(theme.horizontal)
81 .with_set(set.clone()),
82 GradientBlock::new()
83 .title(titles.misc1.0, titles.misc1.1)
84 .with_gradient(theme.misc1)
85 .with_set(set.clone()),
86 GradientBlock::new()
87 .title(titles.misc2.0, titles.misc2.1)
88 .with_gradient(theme.misc2)
89 .with_set(set.clone()),
90 ];
91
92 loop {
93 terminal.draw(|f| {
94 let base = Layout::new(
95 Direction::Vertical,
96 [
97 Constraint::Percentage(50),
98 Constraint::Percentage(50),
99 ],
100 )
101 .split(f.area());
102 let top = Layout::new(
103 Direction::Horizontal,
104 [
105 Constraint::Percentage(14),
106 Constraint::Percentage(14),
107 Constraint::Percentage(14),
108 Constraint::Percentage(14),
109 Constraint::Percentage(14),
110 Constraint::Percentage(15),
111 Constraint::Percentage(15),
112 ],
113 )
114 .split(base[0]);
115 let bottom = Layout::new(
116 Direction::Horizontal,
117 [
118 Constraint::Percentage(14),
119 Constraint::Percentage(14),
120 Constraint::Percentage(14),
121 Constraint::Percentage(14),
122 Constraint::Percentage(14),
123 Constraint::Percentage(15),
124 Constraint::Percentage(15),
125 ],
126 )
127 .split(base[1]);
128 for (block, area) in blocks_top.iter().zip(top.iter()) {
129 f.render_widget(block, *area);
130 }
131 for (block, area) in
132 blocks_bottom.iter().zip(bottom.iter())
133 {
134 f.render_widget(block, *area);
135 }
136 })?;
137 let event = event::read()?;
138
139 if let Event::Key(key_event) = event {
140 if key_event.kind == KeyEventKind::Press {
141 if let KeyCode::Char('q') = key_event.code {
142 break Ok(());
143 }
144 }
145 }
146 }
147}14fn run(
15 terminal: &mut ratatui::DefaultTerminal,
16 set: SegmentSet,
17) -> io::Result<()> {
18 use ratatui::layout::{Constraint, Direction, Layout};
19 use tui_gradient_block::{
20 gradient_block::GradientBlock,
21 theme_presets::misc::t_monochrome,
22 };
23 let titles = t_monochrome::titles();
24 let theme = t_monochrome::full();
25 let blocks_top = vec![
26 GradientBlock::new()
27 .title(titles.up.0, titles.up.1)
28 .with_gradient(theme.up)
29 .with_set(set.clone()),
30 GradientBlock::new()
31 .title(titles.down.0, titles.down.1)
32 .with_gradient(theme.down)
33 .with_set(set.clone()),
34 GradientBlock::new()
35 .title(titles.left.0, titles.left.1)
36 .with_gradient(theme.left)
37 .with_set(set.clone()),
38 GradientBlock::new()
39 .title(titles.right.0, titles.right.1)
40 .with_gradient(theme.right)
41 .with_set(set.clone()),
42 GradientBlock::new()
43 .title(titles.top_left.0, titles.top_left.1)
44 .with_gradient(theme.top_left)
45 .with_set(set.clone()),
46 GradientBlock::new()
47 .title(titles.top_right.0, titles.top_right.1)
48 .with_gradient(theme.top_right)
49 .with_set(set.clone()),
50 GradientBlock::new()
51 .title(titles.bottom_left.0, titles.bottom_left.1)
52 .with_gradient(theme.bottom_left)
53 .with_set(set.clone()),
54 ];
55 let blocks_bottom = vec![
56 GradientBlock::new()
57 .title(titles.bottom_right.0, titles.bottom_right.1)
58 .with_gradient(theme.bottom_right)
59 .with_set(set.clone()),
60 GradientBlock::new()
61 .title(
62 titles.double_corners_left.0,
63 titles.double_corners_left.1,
64 )
65 .with_gradient(theme.double_corners_left)
66 .with_set(set.clone()),
67 GradientBlock::new()
68 .title(
69 titles.double_corners_right.0,
70 titles.double_corners_right.1,
71 )
72 .with_gradient(theme.double_corners_right)
73 .with_set(set.clone()),
74 GradientBlock::new()
75 .title(titles.vertical.0, titles.vertical.1)
76 .with_gradient(theme.vertical)
77 .with_set(set.clone()),
78 GradientBlock::new()
79 .title(titles.horizontal.0, titles.horizontal.1)
80 .with_gradient(theme.horizontal)
81 .with_set(set.clone()),
82 GradientBlock::new()
83 .title(titles.misc1.0, titles.misc1.1)
84 .with_gradient(theme.misc1)
85 .with_set(set.clone()),
86 GradientBlock::new()
87 .title(titles.misc2.0, titles.misc2.1)
88 .with_gradient(theme.misc2)
89 .with_set(set.clone()),
90 ];
91
92 loop {
93 terminal.draw(|f| {
94 let base = Layout::new(
95 Direction::Vertical,
96 [
97 Constraint::Percentage(50),
98 Constraint::Percentage(50),
99 ],
100 )
101 .split(f.area());
102 let top = Layout::new(
103 Direction::Horizontal,
104 [
105 Constraint::Percentage(14),
106 Constraint::Percentage(14),
107 Constraint::Percentage(14),
108 Constraint::Percentage(14),
109 Constraint::Percentage(14),
110 Constraint::Percentage(15),
111 Constraint::Percentage(15),
112 ],
113 )
114 .split(base[0]);
115 let bottom = Layout::new(
116 Direction::Horizontal,
117 [
118 Constraint::Percentage(14),
119 Constraint::Percentage(14),
120 Constraint::Percentage(14),
121 Constraint::Percentage(14),
122 Constraint::Percentage(14),
123 Constraint::Percentage(15),
124 Constraint::Percentage(15),
125 ],
126 )
127 .split(base[1]);
128 for (block, area) in blocks_top.iter().zip(top.iter()) {
129 f.render_widget(block, *area);
130 }
131 for (block, area) in
132 blocks_bottom.iter().zip(bottom.iter())
133 {
134 f.render_widget(block, *area);
135 }
136 })?;
137 let event = event::read()?;
138
139 if let Event::Key(key_event) = event {
140 if key_event.kind == KeyEventKind::Press {
141 if let KeyCode::Char('q') = key_event.code {
142 break Ok(());
143 }
144 }
145 }
146 }
147}14fn run(
15 terminal: &mut ratatui::DefaultTerminal,
16 set: SegmentSet,
17) -> io::Result<()> {
18 use ratatui::layout::{Constraint, Direction, Layout};
19 use tui_gradient_block::{
20 gradient_block::GradientBlock,
21 theme_presets::cool::t_minty_green,
22 };
23 let titles = t_minty_green::titles();
24 let theme = t_minty_green::full();
25 let blocks_top = vec![
26 GradientBlock::new()
27 .title(titles.up.0, titles.up.1)
28 .with_gradient(theme.up)
29 .with_set(set.clone()),
30 GradientBlock::new()
31 .title(titles.down.0, titles.down.1)
32 .with_gradient(theme.down)
33 .with_set(set.clone()),
34 GradientBlock::new()
35 .title(titles.left.0, titles.left.1)
36 .with_gradient(theme.left)
37 .with_set(set.clone()),
38 GradientBlock::new()
39 .title(titles.right.0, titles.right.1)
40 .with_gradient(theme.right)
41 .with_set(set.clone()),
42 GradientBlock::new()
43 .title(titles.top_left.0, titles.top_left.1)
44 .with_gradient(theme.top_left)
45 .with_set(set.clone()),
46 GradientBlock::new()
47 .title(titles.top_right.0, titles.top_right.1)
48 .with_gradient(theme.top_right)
49 .with_set(set.clone()),
50 GradientBlock::new()
51 .title(titles.bottom_left.0, titles.bottom_left.1)
52 .with_gradient(theme.bottom_left)
53 .with_set(set.clone()),
54 ];
55 let blocks_bottom = vec![
56 GradientBlock::new()
57 .title(titles.bottom_right.0, titles.bottom_right.1)
58 .with_gradient(theme.bottom_right)
59 .with_set(set.clone()),
60 GradientBlock::new()
61 .title(
62 titles.double_corners_left.0,
63 titles.double_corners_left.1,
64 )
65 .with_gradient(theme.double_corners_left)
66 .with_set(set.clone()),
67 GradientBlock::new()
68 .title(
69 titles.double_corners_right.0,
70 titles.double_corners_right.1,
71 )
72 .with_gradient(theme.double_corners_right)
73 .with_set(set.clone()),
74 GradientBlock::new()
75 .title(titles.vertical.0, titles.vertical.1)
76 .with_gradient(theme.vertical)
77 .with_set(set.clone()),
78 GradientBlock::new()
79 .title(titles.horizontal.0, titles.horizontal.1)
80 .with_gradient(theme.horizontal)
81 .with_set(set.clone()),
82 GradientBlock::new()
83 .title(titles.misc1.0, titles.misc1.1)
84 .with_gradient(theme.misc1)
85 .with_set(set.clone()),
86 GradientBlock::new()
87 .title(titles.misc2.0, titles.misc2.1)
88 .with_gradient(theme.misc2)
89 .with_set(set.clone()),
90 ];
91
92 loop {
93 terminal.draw(|f| {
94 let base = Layout::new(
95 Direction::Vertical,
96 [
97 Constraint::Percentage(50),
98 Constraint::Percentage(50),
99 ],
100 )
101 .split(f.area());
102 let top = Layout::new(
103 Direction::Horizontal,
104 [
105 Constraint::Percentage(14),
106 Constraint::Percentage(14),
107 Constraint::Percentage(14),
108 Constraint::Percentage(14),
109 Constraint::Percentage(14),
110 Constraint::Percentage(15),
111 Constraint::Percentage(15),
112 ],
113 )
114 .split(base[0]);
115 let bottom = Layout::new(
116 Direction::Horizontal,
117 [
118 Constraint::Percentage(14),
119 Constraint::Percentage(14),
120 Constraint::Percentage(14),
121 Constraint::Percentage(14),
122 Constraint::Percentage(14),
123 Constraint::Percentage(15),
124 Constraint::Percentage(15),
125 ],
126 )
127 .split(base[1]);
128 for (block, area) in blocks_top.iter().zip(top.iter()) {
129 f.render_widget(block, *area);
130 }
131 for (block, area) in
132 blocks_bottom.iter().zip(bottom.iter())
133 {
134 f.render_widget(block, *area);
135 }
136 })?;
137 let event = event::read()?;
138
139 if let Event::Key(key_event) = event {
140 if key_event.kind == KeyEventKind::Press {
141 if let KeyCode::Char('q') = key_event.code {
142 break Ok(());
143 }
144 }
145 }
146 }
147}14fn run(
15 terminal: &mut ratatui::DefaultTerminal,
16 set: SegmentSet,
17) -> io::Result<()> {
18 use ratatui::layout::{Constraint, Direction, Layout};
19 use tui_gradient_block::{
20 gradient_block::GradientBlock,
21 theme_presets::warm::t_rusty_ruins,
22 };
23 let titles = t_rusty_ruins::titles();
24 let theme = t_rusty_ruins::full();
25 let blocks_top = vec![
26 GradientBlock::new()
27 .title(titles.up.0, titles.up.1)
28 .with_gradient(theme.up)
29 .with_set(set.clone()),
30 GradientBlock::new()
31 .title(titles.down.0, titles.down.1)
32 .with_gradient(theme.down)
33 .with_set(set.clone()),
34 GradientBlock::new()
35 .title(titles.left.0, titles.left.1)
36 .with_gradient(theme.left)
37 .with_set(set.clone()),
38 GradientBlock::new()
39 .title(titles.right.0, titles.right.1)
40 .with_gradient(theme.right)
41 .with_set(set.clone()),
42 GradientBlock::new()
43 .title(titles.top_left.0, titles.top_left.1)
44 .with_gradient(theme.top_left)
45 .with_set(set.clone()),
46 GradientBlock::new()
47 .title(titles.top_right.0, titles.top_right.1)
48 .with_gradient(theme.top_right)
49 .with_set(set.clone()),
50 GradientBlock::new()
51 .title(titles.bottom_left.0, titles.bottom_left.1)
52 .with_gradient(theme.bottom_left)
53 .with_set(set.clone()),
54 ];
55 let blocks_bottom = vec![
56 GradientBlock::new()
57 .title(titles.bottom_right.0, titles.bottom_right.1)
58 .with_gradient(theme.bottom_right)
59 .with_set(set.clone()),
60 GradientBlock::new()
61 .title(
62 titles.double_corners_left.0,
63 titles.double_corners_left.1,
64 )
65 .with_gradient(theme.double_corners_left)
66 .with_set(set.clone()),
67 GradientBlock::new()
68 .title(
69 titles.double_corners_right.0,
70 titles.double_corners_right.1,
71 )
72 .with_gradient(theme.double_corners_right)
73 .with_set(set.clone()),
74 GradientBlock::new()
75 .title(titles.vertical.0, titles.vertical.1)
76 .with_gradient(theme.vertical)
77 .with_set(set.clone()),
78 GradientBlock::new()
79 .title(titles.horizontal.0, titles.horizontal.1)
80 .with_gradient(theme.horizontal)
81 .with_set(set.clone()),
82 GradientBlock::new()
83 .title(titles.misc1.0, titles.misc1.1)
84 .with_gradient(theme.misc1)
85 .with_set(set.clone()),
86 GradientBlock::new()
87 .title(titles.misc2.0, titles.misc2.1)
88 .with_gradient(theme.misc2)
89 .with_set(set.clone()),
90 ];
91
92 loop {
93 terminal.draw(|f| {
94 let base = Layout::new(
95 Direction::Vertical,
96 [
97 Constraint::Percentage(50),
98 Constraint::Percentage(50),
99 ],
100 )
101 .split(f.area());
102 let top = Layout::new(
103 Direction::Horizontal,
104 [
105 Constraint::Percentage(14),
106 Constraint::Percentage(14),
107 Constraint::Percentage(14),
108 Constraint::Percentage(14),
109 Constraint::Percentage(14),
110 Constraint::Percentage(15),
111 Constraint::Percentage(15),
112 ],
113 )
114 .split(base[0]);
115 let bottom = Layout::new(
116 Direction::Horizontal,
117 [
118 Constraint::Percentage(14),
119 Constraint::Percentage(14),
120 Constraint::Percentage(14),
121 Constraint::Percentage(14),
122 Constraint::Percentage(14),
123 Constraint::Percentage(15),
124 Constraint::Percentage(15),
125 ],
126 )
127 .split(base[1]);
128 for (block, area) in blocks_top.iter().zip(top.iter()) {
129 f.render_widget(block, *area);
130 }
131 for (block, area) in
132 blocks_bottom.iter().zip(bottom.iter())
133 {
134 f.render_widget(block, *area);
135 }
136 })?;
137 let event = event::read()?;
138
139 if let Event::Key(key_event) = event {
140 if key_event.kind == KeyEventKind::Press {
141 if let KeyCode::Char('q') = key_event.code {
142 break Ok(());
143 }
144 }
145 }
146 }
147}14fn run(
15 terminal: &mut ratatui::DefaultTerminal,
16 set: SegmentSet,
17) -> io::Result<()> {
18 use ratatui::layout::{Constraint, Direction, Layout};
19 use tui_gradient_block::{
20 gradient_block::GradientBlock,
21 theme_presets::dark::t_midnight_blurple,
22 };
23 let titles = t_midnight_blurple::titles();
24 let theme = t_midnight_blurple::full();
25 let blocks_top = vec![
26 GradientBlock::new()
27 .title(titles.up.0, titles.up.1)
28 .with_gradient(theme.up)
29 .with_set(set.clone()),
30 GradientBlock::new()
31 .title(titles.down.0, titles.down.1)
32 .with_gradient(theme.down)
33 .with_set(set.clone()),
34 GradientBlock::new()
35 .title(titles.left.0, titles.left.1)
36 .with_gradient(theme.left)
37 .with_set(set.clone()),
38 GradientBlock::new()
39 .title(titles.right.0, titles.right.1)
40 .with_gradient(theme.right)
41 .with_set(set.clone()),
42 GradientBlock::new()
43 .title(titles.top_left.0, titles.top_left.1)
44 .with_gradient(theme.top_left)
45 .with_set(set.clone()),
46 GradientBlock::new()
47 .title(titles.top_right.0, titles.top_right.1)
48 .with_gradient(theme.top_right)
49 .with_set(set.clone()),
50 GradientBlock::new()
51 .title(titles.bottom_left.0, titles.bottom_left.1)
52 .with_gradient(theme.bottom_left)
53 .with_set(set.clone()),
54 ];
55 let blocks_bottom = vec![
56 GradientBlock::new()
57 .title(titles.bottom_right.0, titles.bottom_right.1)
58 .with_gradient(theme.bottom_right)
59 .with_set(set.clone()),
60 GradientBlock::new()
61 .title(
62 titles.double_corners_left.0,
63 titles.double_corners_left.1,
64 )
65 .with_gradient(theme.double_corners_left)
66 .with_set(set.clone()),
67 GradientBlock::new()
68 .title(
69 titles.double_corners_right.0,
70 titles.double_corners_right.1,
71 )
72 .with_gradient(theme.double_corners_right)
73 .with_set(set.clone()),
74 GradientBlock::new()
75 .title(titles.vertical.0, titles.vertical.1)
76 .with_gradient(theme.vertical)
77 .with_set(set.clone()),
78 GradientBlock::new()
79 .title(titles.horizontal.0, titles.horizontal.1)
80 .with_gradient(theme.horizontal)
81 .with_set(set.clone()),
82 GradientBlock::new()
83 .title(titles.misc1.0, titles.misc1.1)
84 .with_gradient(theme.misc1)
85 .with_set(set.clone()),
86 GradientBlock::new()
87 .title(titles.misc2.0, titles.misc2.1)
88 .with_gradient(theme.misc2)
89 .with_set(set.clone()),
90 ];
91
92 loop {
93 terminal.draw(|f| {
94 let base = Layout::new(
95 Direction::Vertical,
96 [
97 Constraint::Percentage(50),
98 Constraint::Percentage(50),
99 ],
100 )
101 .split(f.area());
102 let top = Layout::new(
103 Direction::Horizontal,
104 [
105 Constraint::Percentage(14),
106 Constraint::Percentage(14),
107 Constraint::Percentage(14),
108 Constraint::Percentage(14),
109 Constraint::Percentage(14),
110 Constraint::Percentage(15),
111 Constraint::Percentage(15),
112 ],
113 )
114 .split(base[0]);
115 let bottom = Layout::new(
116 Direction::Horizontal,
117 [
118 Constraint::Percentage(14),
119 Constraint::Percentage(14),
120 Constraint::Percentage(14),
121 Constraint::Percentage(14),
122 Constraint::Percentage(14),
123 Constraint::Percentage(15),
124 Constraint::Percentage(15),
125 ],
126 )
127 .split(base[1]);
128 for (block, area) in blocks_top.iter().zip(top.iter()) {
129 f.render_widget(block, *area);
130 }
131 for (block, area) in
132 blocks_bottom.iter().zip(bottom.iter())
133 {
134 f.render_widget(block, *area);
135 }
136 })?;
137 let event = event::read()?;
138
139 if let Event::Key(key_event) = event {
140 if key_event.kind == KeyEventKind::Press {
141 if let KeyCode::Char('q') = key_event.code {
142 break Ok(());
143 }
144 }
145 }
146 }
147}Sourcepub fn right_gradient(self, gradient: G) -> Self
pub fn right_gradient(self, gradient: G) -> Self
Sets gradient of the right segment of the border.
Examples found in repository?
24fn run(
25 terminal: &mut ratatui::DefaultTerminal,
26 set: SegmentSet,
27) -> io::Result<()> {
28 use tui_gradient_block::gradient_block::GradientBlock;
29 let block = GradientBlock::new()
30 .with_set(set)
31 .left_gradient(solid((48, 174, 209)))
32 .bottom_gradient(solid((48, 174, 209)))
33 .top_gradient(Box::new(
34 GradientBuilder::new()
35 .colors(&[
36 Color::from_rgba8(48, 174, 209, 1),
37 Color::from_rgba8(225, 22, 247, 1),
38 ])
39 .build::<colorgrad::LinearGradient>()
40 .unwrap(),
41 ))
42 .right_gradient(Box::new(
43 GradientBuilder::new()
44 .colors(&[
45 Color::from_rgba8(225, 22, 247, 1),
46 Color::from_rgba8(48, 174, 209, 1),
47 ])
48 .build::<colorgrad::LinearGradient>()
49 .unwrap(),
50 ));
51
52 loop {
53 terminal.draw(|f| f.render_widget(&block, f.area()))?;
54 let event = event::read()?;
55
56 if let Event::Key(key_event) = event {
57 if key_event.kind == KeyEventKind::Press {
58 if let KeyCode::Char('q') = key_event.code {
59 break Ok(());
60 }
61 }
62 }
63 }
64}Sourcepub fn left_gradient(self, gradient: G) -> Self
pub fn left_gradient(self, gradient: G) -> Self
Sets gradient of the left segment of the border.
Examples found in repository?
24fn run(
25 terminal: &mut ratatui::DefaultTerminal,
26 set: SegmentSet,
27) -> io::Result<()> {
28 use tui_gradient_block::gradient_block::GradientBlock;
29 let block = GradientBlock::new()
30 .with_set(set)
31 .left_gradient(solid((48, 174, 209)))
32 .bottom_gradient(solid((48, 174, 209)))
33 .top_gradient(Box::new(
34 GradientBuilder::new()
35 .colors(&[
36 Color::from_rgba8(48, 174, 209, 1),
37 Color::from_rgba8(225, 22, 247, 1),
38 ])
39 .build::<colorgrad::LinearGradient>()
40 .unwrap(),
41 ))
42 .right_gradient(Box::new(
43 GradientBuilder::new()
44 .colors(&[
45 Color::from_rgba8(225, 22, 247, 1),
46 Color::from_rgba8(48, 174, 209, 1),
47 ])
48 .build::<colorgrad::LinearGradient>()
49 .unwrap(),
50 ));
51
52 loop {
53 terminal.draw(|f| f.render_widget(&block, f.area()))?;
54 let event = event::read()?;
55
56 if let Event::Key(key_event) = event {
57 if key_event.kind == KeyEventKind::Press {
58 if let KeyCode::Char('q') = key_event.code {
59 break Ok(());
60 }
61 }
62 }
63 }
64}Sourcepub fn top_gradient(self, gradient: G) -> Self
pub fn top_gradient(self, gradient: G) -> Self
Sets gradient of the top segment of the border.
Examples found in repository?
24fn run(
25 terminal: &mut ratatui::DefaultTerminal,
26 set: SegmentSet,
27) -> io::Result<()> {
28 use tui_gradient_block::gradient_block::GradientBlock;
29 let block = GradientBlock::new()
30 .with_set(set)
31 .left_gradient(solid((48, 174, 209)))
32 .bottom_gradient(solid((48, 174, 209)))
33 .top_gradient(Box::new(
34 GradientBuilder::new()
35 .colors(&[
36 Color::from_rgba8(48, 174, 209, 1),
37 Color::from_rgba8(225, 22, 247, 1),
38 ])
39 .build::<colorgrad::LinearGradient>()
40 .unwrap(),
41 ))
42 .right_gradient(Box::new(
43 GradientBuilder::new()
44 .colors(&[
45 Color::from_rgba8(225, 22, 247, 1),
46 Color::from_rgba8(48, 174, 209, 1),
47 ])
48 .build::<colorgrad::LinearGradient>()
49 .unwrap(),
50 ));
51
52 loop {
53 terminal.draw(|f| f.render_widget(&block, f.area()))?;
54 let event = event::read()?;
55
56 if let Event::Key(key_event) = event {
57 if key_event.kind == KeyEventKind::Press {
58 if let KeyCode::Char('q') = key_event.code {
59 break Ok(());
60 }
61 }
62 }
63 }
64}Sourcepub fn bottom_gradient(self, gradient: G) -> Self
pub fn bottom_gradient(self, gradient: G) -> Self
Sets gradient of the bottom segment of the border.
Examples found in repository?
24fn run(
25 terminal: &mut ratatui::DefaultTerminal,
26 set: SegmentSet,
27) -> io::Result<()> {
28 use tui_gradient_block::gradient_block::GradientBlock;
29 let block = GradientBlock::new()
30 .with_set(set)
31 .left_gradient(solid((48, 174, 209)))
32 .bottom_gradient(solid((48, 174, 209)))
33 .top_gradient(Box::new(
34 GradientBuilder::new()
35 .colors(&[
36 Color::from_rgba8(48, 174, 209, 1),
37 Color::from_rgba8(225, 22, 247, 1),
38 ])
39 .build::<colorgrad::LinearGradient>()
40 .unwrap(),
41 ))
42 .right_gradient(Box::new(
43 GradientBuilder::new()
44 .colors(&[
45 Color::from_rgba8(225, 22, 247, 1),
46 Color::from_rgba8(48, 174, 209, 1),
47 ])
48 .build::<colorgrad::LinearGradient>()
49 .unwrap(),
50 ));
51
52 loop {
53 terminal.draw(|f| f.render_widget(&block, f.area()))?;
54 let event = event::read()?;
55
56 if let Event::Key(key_event) = event {
57 if key_event.kind == KeyEventKind::Press {
58 if let KeyCode::Char('q') = key_event.code {
59 break Ok(());
60 }
61 }
62 }
63 }
64}pub fn margin(self, horizontal: u16, vertical: u16) -> Self
pub fn horizontal_margin(self, margin: u16) -> Self
pub fn vertical_margin(self, margin: u16) -> Self
pub fn right_padding(self, padding: u16) -> Self
pub fn left_padding(self, padding: u16) -> Self
pub fn top_padding(self, padding: u16) -> Self
pub fn bottom_padding(self, padding: u16) -> Self
pub fn borders(self, borders: Borders, corners: bool) -> Self
pub fn corners(self, corners: Corners) -> Self
pub fn center_symbols(self, symbols: CenterSymbols) -> Self
Sourcepub fn title_top<I: Into<Line<'a>>>(self, title: I) -> Self
pub fn title_top<I: Into<Line<'a>>>(self, title: I) -> Self
Examples found in repository?
15fn run(
16 terminal: &mut ratatui::DefaultTerminal,
17 set: SegmentSet,
18) -> io::Result<()> {
19 use ratatui::{text::Line, layout::{Constraint, Direction, Layout}};
20 use tui_gradient_block::{
21 gradient_block::GradientBlock,
22 theme_presets::cool::t_zombie_dreams,
23 };
24 let theme = t_zombie_dreams::full();
25 let blocks = vec![
26 GradientBlock::new()
27 .with_gradient(theme.double_corners_left)
28 .with_set(set.clone()),
29 GradientBlock::new().title_top(Line::from(tui_rule::generate_gradient_text!("Zombie Dreams", theme.right.top)).centered())
30 .with_gradient(theme.misc1)
31 .with_set(set.clone()),
32 GradientBlock::new()
33 .with_gradient(theme.double_corners_right)
34 .with_set(set.clone()),
35 ];
36
37 loop {
38 terminal.draw(|f| {
39 let base = Layout::new(
40 Direction::Horizontal,
41 [
42 Constraint::Percentage(33),
43 Constraint::Percentage(33),
44 Constraint::Percentage(34),
45 ],
46 )
47 .vertical_margin(1)
48 .horizontal_margin(1)
49 .spacing(3)
50 .split(f.area());
51 for (block, area) in blocks.iter().zip(base.iter()) {
52 f.render_widget(block, *area);
53 }
54 })?;
55 let event = event::read()?;
56
57 if let Event::Key(key_event) = event {
58 if key_event.kind == KeyEventKind::Press {
59 if let KeyCode::Char('q') = key_event.code {
60 break Ok(());
61 }
62 }
63 }
64 }
65}pub fn title_bottom<I: Into<Line<'a>>>(self, title: I) -> Self
Sourcepub fn with_border_style(self, style: BorderStyle) -> Self
pub fn with_border_style(self, style: BorderStyle) -> Self
Sets the border style for the block.
If this function is not called, the border will be plain by default.
§Parameters
style: ABorderStyleenum value that determines the appearance of the border.BorderStyle::New: Empty to be set manually.BorderStyle::Custom: Custom border fromSegmentSetstruct
§Example 1: Using a standard border style
let border = GradientBlock::new().border_style(BorderStyle::Double);§Example 2: Using a miscellaneous border style
let border = GradientBlock::new().with_border_style(BorderStyle::Custom(preset::MISC3));§Example 3: Using a custom border type
let border = GradientBlock::new()
.with_border_style(BorderStyle::New)
.top_left('╔')
.top_right('╗')
.bottom_left('╚')
.bottom_right('╝');Sets the border style of the block.
This function allows setting a predefined border style or a custom one.
§Parameters
style: ABorderStyleenum variant specifying the desired border style.
§Behavior
BorderStyle::CustomBorderType: Does not set predefined symbols, allowing manual customization.BorderStyle::MiscBorder(MiscBorderTypes): Uses a predefined miscellaneous border style.BorderStyle::Plain,BorderStyle::Double,BorderStyle::Thick,BorderStyle::Rounded: Sets the block’s borders to one of these predefined styles.
§Example
let block = GradientBlock::new().border_style(BorderStyle::Double);Sourcepub fn titles(self, titles: &'a [(Line<'_>, Position)]) -> Self
pub fn titles(self, titles: &'a [(Line<'_>, Position)]) -> Self
Sets the titles that appear at the bottom of the border.
§Parameters
titles: A vector of tuples where each tuple contains:- A
Stringrepresenting the title text. - A
Alignmentindicating how the title should be aligned (e.g., left, center, right). - An optional tuple containing a vector of RGB colors and a gradient factor (f32).
- A
§Example
let border = Border::new().bottom_titles(vec![
("Footer", Alignment::Center, Some((vec![(255, 0, 0), (190, 3, 252)], 0.5))),
]);Sourcepub fn title(self, title: Line<'a>, pos: Position) -> Self
pub fn title(self, title: Line<'a>, pos: Position) -> Self
Examples found in repository?
14fn run(
15 terminal: &mut ratatui::DefaultTerminal,
16 set: SegmentSet,
17) -> io::Result<()> {
18 use ratatui::layout::{Constraint, Direction, Layout};
19 use tui_gradient_block::{
20 gradient_block::GradientBlock,
21 theme_presets::cool::t_misty_blue,
22 };
23 let titles = t_misty_blue::titles();
24 let theme = t_misty_blue::full();
25 let blocks_top = vec![
26 GradientBlock::new()
27 .title(titles.up.0, titles.up.1)
28 .with_gradient(theme.up)
29 .with_set(set.clone()),
30 GradientBlock::new()
31 .title(titles.down.0, titles.down.1)
32 .with_gradient(theme.down)
33 .with_set(set.clone()),
34 GradientBlock::new()
35 .title(titles.left.0, titles.left.1)
36 .with_gradient(theme.left)
37 .with_set(set.clone()),
38 GradientBlock::new()
39 .title(titles.right.0, titles.right.1)
40 .with_gradient(theme.right)
41 .with_set(set.clone()),
42 GradientBlock::new()
43 .title(titles.top_left.0, titles.top_left.1)
44 .with_gradient(theme.top_left)
45 .with_set(set.clone()),
46 GradientBlock::new()
47 .title(titles.top_right.0, titles.top_right.1)
48 .with_gradient(theme.top_right)
49 .with_set(set.clone()),
50 GradientBlock::new()
51 .title(titles.bottom_left.0, titles.bottom_left.1)
52 .with_gradient(theme.bottom_left)
53 .with_set(set.clone()),
54 ];
55 let blocks_bottom = vec![
56 GradientBlock::new()
57 .title(titles.bottom_right.0, titles.bottom_right.1)
58 .with_gradient(theme.bottom_right)
59 .with_set(set.clone()),
60 GradientBlock::new()
61 .title(
62 titles.double_corners_left.0,
63 titles.double_corners_left.1,
64 )
65 .with_gradient(theme.double_corners_left)
66 .with_set(set.clone()),
67 GradientBlock::new()
68 .title(
69 titles.double_corners_right.0,
70 titles.double_corners_right.1,
71 )
72 .with_gradient(theme.double_corners_right)
73 .with_set(set.clone()),
74 GradientBlock::new()
75 .title(titles.vertical.0, titles.vertical.1)
76 .with_gradient(theme.vertical)
77 .with_set(set.clone()),
78 GradientBlock::new()
79 .title(titles.horizontal.0, titles.horizontal.1)
80 .with_gradient(theme.horizontal)
81 .with_set(set.clone()),
82 GradientBlock::new()
83 .title(titles.misc1.0, titles.misc1.1)
84 .with_gradient(theme.misc1)
85 .with_set(set.clone()),
86 GradientBlock::new()
87 .title(titles.misc2.0, titles.misc2.1)
88 .with_gradient(theme.misc2)
89 .with_set(set.clone()),
90 ];
91
92 loop {
93 terminal.draw(|f| {
94 let base = Layout::new(
95 Direction::Vertical,
96 [
97 Constraint::Percentage(50),
98 Constraint::Percentage(50),
99 ],
100 )
101 .split(f.area());
102 let top = Layout::new(
103 Direction::Horizontal,
104 [
105 Constraint::Percentage(14),
106 Constraint::Percentage(14),
107 Constraint::Percentage(14),
108 Constraint::Percentage(14),
109 Constraint::Percentage(14),
110 Constraint::Percentage(15),
111 Constraint::Percentage(15),
112 ],
113 )
114 .split(base[0]);
115 let bottom = Layout::new(
116 Direction::Horizontal,
117 [
118 Constraint::Percentage(14),
119 Constraint::Percentage(14),
120 Constraint::Percentage(14),
121 Constraint::Percentage(14),
122 Constraint::Percentage(14),
123 Constraint::Percentage(15),
124 Constraint::Percentage(15),
125 ],
126 )
127 .split(base[1]);
128 for (block, area) in blocks_top.iter().zip(top.iter()) {
129 f.render_widget(block, *area);
130 }
131 for (block, area) in
132 blocks_bottom.iter().zip(bottom.iter())
133 {
134 f.render_widget(block, *area);
135 }
136 })?;
137 let event = event::read()?;
138
139 if let Event::Key(key_event) = event {
140 if key_event.kind == KeyEventKind::Press {
141 if let KeyCode::Char('q') = key_event.code {
142 break Ok(());
143 }
144 }
145 }
146 }
147}More examples
14fn run(
15 terminal: &mut ratatui::DefaultTerminal,
16 set: SegmentSet,
17) -> io::Result<()> {
18 use ratatui::layout::{Constraint, Direction, Layout};
19 use tui_gradient_block::{
20 gradient_block::GradientBlock,
21 theme_presets::misc::t_monochrome,
22 };
23 let titles = t_monochrome::titles();
24 let theme = t_monochrome::full();
25 let blocks_top = vec![
26 GradientBlock::new()
27 .title(titles.up.0, titles.up.1)
28 .with_gradient(theme.up)
29 .with_set(set.clone()),
30 GradientBlock::new()
31 .title(titles.down.0, titles.down.1)
32 .with_gradient(theme.down)
33 .with_set(set.clone()),
34 GradientBlock::new()
35 .title(titles.left.0, titles.left.1)
36 .with_gradient(theme.left)
37 .with_set(set.clone()),
38 GradientBlock::new()
39 .title(titles.right.0, titles.right.1)
40 .with_gradient(theme.right)
41 .with_set(set.clone()),
42 GradientBlock::new()
43 .title(titles.top_left.0, titles.top_left.1)
44 .with_gradient(theme.top_left)
45 .with_set(set.clone()),
46 GradientBlock::new()
47 .title(titles.top_right.0, titles.top_right.1)
48 .with_gradient(theme.top_right)
49 .with_set(set.clone()),
50 GradientBlock::new()
51 .title(titles.bottom_left.0, titles.bottom_left.1)
52 .with_gradient(theme.bottom_left)
53 .with_set(set.clone()),
54 ];
55 let blocks_bottom = vec![
56 GradientBlock::new()
57 .title(titles.bottom_right.0, titles.bottom_right.1)
58 .with_gradient(theme.bottom_right)
59 .with_set(set.clone()),
60 GradientBlock::new()
61 .title(
62 titles.double_corners_left.0,
63 titles.double_corners_left.1,
64 )
65 .with_gradient(theme.double_corners_left)
66 .with_set(set.clone()),
67 GradientBlock::new()
68 .title(
69 titles.double_corners_right.0,
70 titles.double_corners_right.1,
71 )
72 .with_gradient(theme.double_corners_right)
73 .with_set(set.clone()),
74 GradientBlock::new()
75 .title(titles.vertical.0, titles.vertical.1)
76 .with_gradient(theme.vertical)
77 .with_set(set.clone()),
78 GradientBlock::new()
79 .title(titles.horizontal.0, titles.horizontal.1)
80 .with_gradient(theme.horizontal)
81 .with_set(set.clone()),
82 GradientBlock::new()
83 .title(titles.misc1.0, titles.misc1.1)
84 .with_gradient(theme.misc1)
85 .with_set(set.clone()),
86 GradientBlock::new()
87 .title(titles.misc2.0, titles.misc2.1)
88 .with_gradient(theme.misc2)
89 .with_set(set.clone()),
90 ];
91
92 loop {
93 terminal.draw(|f| {
94 let base = Layout::new(
95 Direction::Vertical,
96 [
97 Constraint::Percentage(50),
98 Constraint::Percentage(50),
99 ],
100 )
101 .split(f.area());
102 let top = Layout::new(
103 Direction::Horizontal,
104 [
105 Constraint::Percentage(14),
106 Constraint::Percentage(14),
107 Constraint::Percentage(14),
108 Constraint::Percentage(14),
109 Constraint::Percentage(14),
110 Constraint::Percentage(15),
111 Constraint::Percentage(15),
112 ],
113 )
114 .split(base[0]);
115 let bottom = Layout::new(
116 Direction::Horizontal,
117 [
118 Constraint::Percentage(14),
119 Constraint::Percentage(14),
120 Constraint::Percentage(14),
121 Constraint::Percentage(14),
122 Constraint::Percentage(14),
123 Constraint::Percentage(15),
124 Constraint::Percentage(15),
125 ],
126 )
127 .split(base[1]);
128 for (block, area) in blocks_top.iter().zip(top.iter()) {
129 f.render_widget(block, *area);
130 }
131 for (block, area) in
132 blocks_bottom.iter().zip(bottom.iter())
133 {
134 f.render_widget(block, *area);
135 }
136 })?;
137 let event = event::read()?;
138
139 if let Event::Key(key_event) = event {
140 if key_event.kind == KeyEventKind::Press {
141 if let KeyCode::Char('q') = key_event.code {
142 break Ok(());
143 }
144 }
145 }
146 }
147}14fn run(
15 terminal: &mut ratatui::DefaultTerminal,
16 set: SegmentSet,
17) -> io::Result<()> {
18 use ratatui::layout::{Constraint, Direction, Layout};
19 use tui_gradient_block::{
20 gradient_block::GradientBlock,
21 theme_presets::cool::t_minty_green,
22 };
23 let titles = t_minty_green::titles();
24 let theme = t_minty_green::full();
25 let blocks_top = vec![
26 GradientBlock::new()
27 .title(titles.up.0, titles.up.1)
28 .with_gradient(theme.up)
29 .with_set(set.clone()),
30 GradientBlock::new()
31 .title(titles.down.0, titles.down.1)
32 .with_gradient(theme.down)
33 .with_set(set.clone()),
34 GradientBlock::new()
35 .title(titles.left.0, titles.left.1)
36 .with_gradient(theme.left)
37 .with_set(set.clone()),
38 GradientBlock::new()
39 .title(titles.right.0, titles.right.1)
40 .with_gradient(theme.right)
41 .with_set(set.clone()),
42 GradientBlock::new()
43 .title(titles.top_left.0, titles.top_left.1)
44 .with_gradient(theme.top_left)
45 .with_set(set.clone()),
46 GradientBlock::new()
47 .title(titles.top_right.0, titles.top_right.1)
48 .with_gradient(theme.top_right)
49 .with_set(set.clone()),
50 GradientBlock::new()
51 .title(titles.bottom_left.0, titles.bottom_left.1)
52 .with_gradient(theme.bottom_left)
53 .with_set(set.clone()),
54 ];
55 let blocks_bottom = vec![
56 GradientBlock::new()
57 .title(titles.bottom_right.0, titles.bottom_right.1)
58 .with_gradient(theme.bottom_right)
59 .with_set(set.clone()),
60 GradientBlock::new()
61 .title(
62 titles.double_corners_left.0,
63 titles.double_corners_left.1,
64 )
65 .with_gradient(theme.double_corners_left)
66 .with_set(set.clone()),
67 GradientBlock::new()
68 .title(
69 titles.double_corners_right.0,
70 titles.double_corners_right.1,
71 )
72 .with_gradient(theme.double_corners_right)
73 .with_set(set.clone()),
74 GradientBlock::new()
75 .title(titles.vertical.0, titles.vertical.1)
76 .with_gradient(theme.vertical)
77 .with_set(set.clone()),
78 GradientBlock::new()
79 .title(titles.horizontal.0, titles.horizontal.1)
80 .with_gradient(theme.horizontal)
81 .with_set(set.clone()),
82 GradientBlock::new()
83 .title(titles.misc1.0, titles.misc1.1)
84 .with_gradient(theme.misc1)
85 .with_set(set.clone()),
86 GradientBlock::new()
87 .title(titles.misc2.0, titles.misc2.1)
88 .with_gradient(theme.misc2)
89 .with_set(set.clone()),
90 ];
91
92 loop {
93 terminal.draw(|f| {
94 let base = Layout::new(
95 Direction::Vertical,
96 [
97 Constraint::Percentage(50),
98 Constraint::Percentage(50),
99 ],
100 )
101 .split(f.area());
102 let top = Layout::new(
103 Direction::Horizontal,
104 [
105 Constraint::Percentage(14),
106 Constraint::Percentage(14),
107 Constraint::Percentage(14),
108 Constraint::Percentage(14),
109 Constraint::Percentage(14),
110 Constraint::Percentage(15),
111 Constraint::Percentage(15),
112 ],
113 )
114 .split(base[0]);
115 let bottom = Layout::new(
116 Direction::Horizontal,
117 [
118 Constraint::Percentage(14),
119 Constraint::Percentage(14),
120 Constraint::Percentage(14),
121 Constraint::Percentage(14),
122 Constraint::Percentage(14),
123 Constraint::Percentage(15),
124 Constraint::Percentage(15),
125 ],
126 )
127 .split(base[1]);
128 for (block, area) in blocks_top.iter().zip(top.iter()) {
129 f.render_widget(block, *area);
130 }
131 for (block, area) in
132 blocks_bottom.iter().zip(bottom.iter())
133 {
134 f.render_widget(block, *area);
135 }
136 })?;
137 let event = event::read()?;
138
139 if let Event::Key(key_event) = event {
140 if key_event.kind == KeyEventKind::Press {
141 if let KeyCode::Char('q') = key_event.code {
142 break Ok(());
143 }
144 }
145 }
146 }
147}14fn run(
15 terminal: &mut ratatui::DefaultTerminal,
16 set: SegmentSet,
17) -> io::Result<()> {
18 use ratatui::layout::{Constraint, Direction, Layout};
19 use tui_gradient_block::{
20 gradient_block::GradientBlock,
21 theme_presets::warm::t_rusty_ruins,
22 };
23 let titles = t_rusty_ruins::titles();
24 let theme = t_rusty_ruins::full();
25 let blocks_top = vec![
26 GradientBlock::new()
27 .title(titles.up.0, titles.up.1)
28 .with_gradient(theme.up)
29 .with_set(set.clone()),
30 GradientBlock::new()
31 .title(titles.down.0, titles.down.1)
32 .with_gradient(theme.down)
33 .with_set(set.clone()),
34 GradientBlock::new()
35 .title(titles.left.0, titles.left.1)
36 .with_gradient(theme.left)
37 .with_set(set.clone()),
38 GradientBlock::new()
39 .title(titles.right.0, titles.right.1)
40 .with_gradient(theme.right)
41 .with_set(set.clone()),
42 GradientBlock::new()
43 .title(titles.top_left.0, titles.top_left.1)
44 .with_gradient(theme.top_left)
45 .with_set(set.clone()),
46 GradientBlock::new()
47 .title(titles.top_right.0, titles.top_right.1)
48 .with_gradient(theme.top_right)
49 .with_set(set.clone()),
50 GradientBlock::new()
51 .title(titles.bottom_left.0, titles.bottom_left.1)
52 .with_gradient(theme.bottom_left)
53 .with_set(set.clone()),
54 ];
55 let blocks_bottom = vec![
56 GradientBlock::new()
57 .title(titles.bottom_right.0, titles.bottom_right.1)
58 .with_gradient(theme.bottom_right)
59 .with_set(set.clone()),
60 GradientBlock::new()
61 .title(
62 titles.double_corners_left.0,
63 titles.double_corners_left.1,
64 )
65 .with_gradient(theme.double_corners_left)
66 .with_set(set.clone()),
67 GradientBlock::new()
68 .title(
69 titles.double_corners_right.0,
70 titles.double_corners_right.1,
71 )
72 .with_gradient(theme.double_corners_right)
73 .with_set(set.clone()),
74 GradientBlock::new()
75 .title(titles.vertical.0, titles.vertical.1)
76 .with_gradient(theme.vertical)
77 .with_set(set.clone()),
78 GradientBlock::new()
79 .title(titles.horizontal.0, titles.horizontal.1)
80 .with_gradient(theme.horizontal)
81 .with_set(set.clone()),
82 GradientBlock::new()
83 .title(titles.misc1.0, titles.misc1.1)
84 .with_gradient(theme.misc1)
85 .with_set(set.clone()),
86 GradientBlock::new()
87 .title(titles.misc2.0, titles.misc2.1)
88 .with_gradient(theme.misc2)
89 .with_set(set.clone()),
90 ];
91
92 loop {
93 terminal.draw(|f| {
94 let base = Layout::new(
95 Direction::Vertical,
96 [
97 Constraint::Percentage(50),
98 Constraint::Percentage(50),
99 ],
100 )
101 .split(f.area());
102 let top = Layout::new(
103 Direction::Horizontal,
104 [
105 Constraint::Percentage(14),
106 Constraint::Percentage(14),
107 Constraint::Percentage(14),
108 Constraint::Percentage(14),
109 Constraint::Percentage(14),
110 Constraint::Percentage(15),
111 Constraint::Percentage(15),
112 ],
113 )
114 .split(base[0]);
115 let bottom = Layout::new(
116 Direction::Horizontal,
117 [
118 Constraint::Percentage(14),
119 Constraint::Percentage(14),
120 Constraint::Percentage(14),
121 Constraint::Percentage(14),
122 Constraint::Percentage(14),
123 Constraint::Percentage(15),
124 Constraint::Percentage(15),
125 ],
126 )
127 .split(base[1]);
128 for (block, area) in blocks_top.iter().zip(top.iter()) {
129 f.render_widget(block, *area);
130 }
131 for (block, area) in
132 blocks_bottom.iter().zip(bottom.iter())
133 {
134 f.render_widget(block, *area);
135 }
136 })?;
137 let event = event::read()?;
138
139 if let Event::Key(key_event) = event {
140 if key_event.kind == KeyEventKind::Press {
141 if let KeyCode::Char('q') = key_event.code {
142 break Ok(());
143 }
144 }
145 }
146 }
147}14fn run(
15 terminal: &mut ratatui::DefaultTerminal,
16 set: SegmentSet,
17) -> io::Result<()> {
18 use ratatui::layout::{Constraint, Direction, Layout};
19 use tui_gradient_block::{
20 gradient_block::GradientBlock,
21 theme_presets::dark::t_midnight_blurple,
22 };
23 let titles = t_midnight_blurple::titles();
24 let theme = t_midnight_blurple::full();
25 let blocks_top = vec![
26 GradientBlock::new()
27 .title(titles.up.0, titles.up.1)
28 .with_gradient(theme.up)
29 .with_set(set.clone()),
30 GradientBlock::new()
31 .title(titles.down.0, titles.down.1)
32 .with_gradient(theme.down)
33 .with_set(set.clone()),
34 GradientBlock::new()
35 .title(titles.left.0, titles.left.1)
36 .with_gradient(theme.left)
37 .with_set(set.clone()),
38 GradientBlock::new()
39 .title(titles.right.0, titles.right.1)
40 .with_gradient(theme.right)
41 .with_set(set.clone()),
42 GradientBlock::new()
43 .title(titles.top_left.0, titles.top_left.1)
44 .with_gradient(theme.top_left)
45 .with_set(set.clone()),
46 GradientBlock::new()
47 .title(titles.top_right.0, titles.top_right.1)
48 .with_gradient(theme.top_right)
49 .with_set(set.clone()),
50 GradientBlock::new()
51 .title(titles.bottom_left.0, titles.bottom_left.1)
52 .with_gradient(theme.bottom_left)
53 .with_set(set.clone()),
54 ];
55 let blocks_bottom = vec![
56 GradientBlock::new()
57 .title(titles.bottom_right.0, titles.bottom_right.1)
58 .with_gradient(theme.bottom_right)
59 .with_set(set.clone()),
60 GradientBlock::new()
61 .title(
62 titles.double_corners_left.0,
63 titles.double_corners_left.1,
64 )
65 .with_gradient(theme.double_corners_left)
66 .with_set(set.clone()),
67 GradientBlock::new()
68 .title(
69 titles.double_corners_right.0,
70 titles.double_corners_right.1,
71 )
72 .with_gradient(theme.double_corners_right)
73 .with_set(set.clone()),
74 GradientBlock::new()
75 .title(titles.vertical.0, titles.vertical.1)
76 .with_gradient(theme.vertical)
77 .with_set(set.clone()),
78 GradientBlock::new()
79 .title(titles.horizontal.0, titles.horizontal.1)
80 .with_gradient(theme.horizontal)
81 .with_set(set.clone()),
82 GradientBlock::new()
83 .title(titles.misc1.0, titles.misc1.1)
84 .with_gradient(theme.misc1)
85 .with_set(set.clone()),
86 GradientBlock::new()
87 .title(titles.misc2.0, titles.misc2.1)
88 .with_gradient(theme.misc2)
89 .with_set(set.clone()),
90 ];
91
92 loop {
93 terminal.draw(|f| {
94 let base = Layout::new(
95 Direction::Vertical,
96 [
97 Constraint::Percentage(50),
98 Constraint::Percentage(50),
99 ],
100 )
101 .split(f.area());
102 let top = Layout::new(
103 Direction::Horizontal,
104 [
105 Constraint::Percentage(14),
106 Constraint::Percentage(14),
107 Constraint::Percentage(14),
108 Constraint::Percentage(14),
109 Constraint::Percentage(14),
110 Constraint::Percentage(15),
111 Constraint::Percentage(15),
112 ],
113 )
114 .split(base[0]);
115 let bottom = Layout::new(
116 Direction::Horizontal,
117 [
118 Constraint::Percentage(14),
119 Constraint::Percentage(14),
120 Constraint::Percentage(14),
121 Constraint::Percentage(14),
122 Constraint::Percentage(14),
123 Constraint::Percentage(15),
124 Constraint::Percentage(15),
125 ],
126 )
127 .split(base[1]);
128 for (block, area) in blocks_top.iter().zip(top.iter()) {
129 f.render_widget(block, *area);
130 }
131 for (block, area) in
132 blocks_bottom.iter().zip(bottom.iter())
133 {
134 f.render_widget(block, *area);
135 }
136 })?;
137 let event = event::read()?;
138
139 if let Event::Key(key_event) = event {
140 if key_event.kind == KeyEventKind::Press {
141 if let KeyCode::Char('q') = key_event.code {
142 break Ok(());
143 }
144 }
145 }
146 }
147}Sourcepub const fn bottom_right(self, symb: char) -> Self
pub const fn bottom_right(self, symb: char) -> Self
Sourcepub const fn bottom_left(self, symb: char) -> Self
pub const fn bottom_left(self, symb: char) -> Self
Sourcepub const fn bottom_horizontal_symbol(self, symb: char) -> Self
pub const fn bottom_horizontal_symbol(self, symb: char) -> Self
Sourcepub const fn top_horizontal_symbol(self, symb: char) -> Self
pub const fn top_horizontal_symbol(self, symb: char) -> Self
Sourcepub const fn right_vertical_symbol(self, symb: char) -> Self
pub const fn right_vertical_symbol(self, symb: char) -> Self
Sourcepub const fn left_vertical_symbol(self, symb: char) -> Self
pub const fn left_vertical_symbol(self, symb: char) -> Self
Sets the left vertical border symbol.
§Example
let widget = GradientBlock::new().left_vertical_symbol('|');Sourcepub const fn top_center_symbol(self, symb: char) -> Self
pub const fn top_center_symbol(self, symb: char) -> Self
Sets the top center border symbol.
§Example
let widget = GradientBlock::new().top_center_symbol('─');Sourcepub const fn bottom_center_symbol(self, symb: char) -> Self
pub const fn bottom_center_symbol(self, symb: char) -> Self
Sets the bottom center border symbol.
§Example
let widget = GradientBlock::new().bottom_center_symbol('═');Sourcepub const fn left_center_symbol(self, symb: char) -> Self
pub const fn left_center_symbol(self, symb: char) -> Self
Sets the left center vertical border symbol.
§Example
let widget = GradientBlock::new().left_center_symbol('+');Sourcepub const fn right_center_symbol(self, symb: char) -> Self
pub const fn right_center_symbol(self, symb: char) -> Self
Sets the right center vertical border symbol.
§Example
let widget = GradientBlock::new().right_center_symbol('+');Sourcepub fn top_horizontal_right_symbol(self, symb: char) -> Self
pub fn top_horizontal_right_symbol(self, symb: char) -> Self
Sets the top right horizontal border symbol.
§Example
let widget = GradientBlock::new().top_horizontal_right_symbol('┐');Sourcepub const fn bottom_horizontal_right_symbol(self, symb: char) -> Self
pub const fn bottom_horizontal_right_symbol(self, symb: char) -> Self
Sets the symbol used for the repeated section of the bottom horizontal border (right side).
§Example
let block = GradientBlock::new().bottom_horizontal_right_symbol('*');Sourcepub const fn top_horizontal_left_symbol(self, symb: char) -> Self
pub const fn top_horizontal_left_symbol(self, symb: char) -> Self
Sets the symbol for the top horizontal left connector.
§Example
let block = GradientBlock::new().top_horizontal_left_symbol('=');Sourcepub const fn bottom_horizontal_left_symbol(self, symb: char) -> Self
pub const fn bottom_horizontal_left_symbol(self, symb: char) -> Self
Sets the symbol for the bottom horizontal left connector.
§Example
let block = GradientBlock::new().bottom_horizontal_left_symbol('=');Sourcepub const fn top_vertical_right_symbol(self, symb: char) -> Self
pub const fn top_vertical_right_symbol(self, symb: char) -> Self
Sets the symbol for the top vertical right connector.
§Example
let block = GradientBlock::new().top_vertical_right_symbol('|');Sourcepub const fn bottom_vertical_right_symbol(self, symb: char) -> Self
pub const fn bottom_vertical_right_symbol(self, symb: char) -> Self
Sets the symbol for the bottom vertical right connector.
§Example
let block = GradientBlock::new().bottom_vertical_right_symbol('|');Sourcepub const fn top_vertical_left_symbol(self, symb: char) -> Self
pub const fn top_vertical_left_symbol(self, symb: char) -> Self
Sets the symbol for the top vertical left connector.
§Example
let block = GradientBlock::new().top_vertical_left_symbol('|');Sourcepub fn with_set(self, set: SS) -> Self
pub fn with_set(self, set: SS) -> Self
Examples found in repository?
24fn run(
25 terminal: &mut ratatui::DefaultTerminal,
26 set: SegmentSet,
27) -> io::Result<()> {
28 use tui_gradient_block::gradient_block::GradientBlock;
29 let block = GradientBlock::new()
30 .with_set(set)
31 .left_gradient(solid((48, 174, 209)))
32 .bottom_gradient(solid((48, 174, 209)))
33 .top_gradient(Box::new(
34 GradientBuilder::new()
35 .colors(&[
36 Color::from_rgba8(48, 174, 209, 1),
37 Color::from_rgba8(225, 22, 247, 1),
38 ])
39 .build::<colorgrad::LinearGradient>()
40 .unwrap(),
41 ))
42 .right_gradient(Box::new(
43 GradientBuilder::new()
44 .colors(&[
45 Color::from_rgba8(225, 22, 247, 1),
46 Color::from_rgba8(48, 174, 209, 1),
47 ])
48 .build::<colorgrad::LinearGradient>()
49 .unwrap(),
50 ));
51
52 loop {
53 terminal.draw(|f| f.render_widget(&block, f.area()))?;
54 let event = event::read()?;
55
56 if let Event::Key(key_event) = event {
57 if key_event.kind == KeyEventKind::Press {
58 if let KeyCode::Char('q') = key_event.code {
59 break Ok(());
60 }
61 }
62 }
63 }
64}More examples
15fn run(
16 terminal: &mut ratatui::DefaultTerminal,
17 set: SegmentSet,
18) -> io::Result<()> {
19 use ratatui::{text::Line, layout::{Constraint, Direction, Layout}};
20 use tui_gradient_block::{
21 gradient_block::GradientBlock,
22 theme_presets::cool::t_zombie_dreams,
23 };
24 let theme = t_zombie_dreams::full();
25 let blocks = vec![
26 GradientBlock::new()
27 .with_gradient(theme.double_corners_left)
28 .with_set(set.clone()),
29 GradientBlock::new().title_top(Line::from(tui_rule::generate_gradient_text!("Zombie Dreams", theme.right.top)).centered())
30 .with_gradient(theme.misc1)
31 .with_set(set.clone()),
32 GradientBlock::new()
33 .with_gradient(theme.double_corners_right)
34 .with_set(set.clone()),
35 ];
36
37 loop {
38 terminal.draw(|f| {
39 let base = Layout::new(
40 Direction::Horizontal,
41 [
42 Constraint::Percentage(33),
43 Constraint::Percentage(33),
44 Constraint::Percentage(34),
45 ],
46 )
47 .vertical_margin(1)
48 .horizontal_margin(1)
49 .spacing(3)
50 .split(f.area());
51 for (block, area) in blocks.iter().zip(base.iter()) {
52 f.render_widget(block, *area);
53 }
54 })?;
55 let event = event::read()?;
56
57 if let Event::Key(key_event) = event {
58 if key_event.kind == KeyEventKind::Press {
59 if let KeyCode::Char('q') = key_event.code {
60 break Ok(());
61 }
62 }
63 }
64 }
65}14fn run(
15 terminal: &mut ratatui::DefaultTerminal,
16 set: SegmentSet,
17) -> io::Result<()> {
18 use ratatui::layout::{Constraint, Direction, Layout};
19 use tui_gradient_block::{
20 gradient_block::GradientBlock,
21 theme_presets::cool::t_misty_blue,
22 };
23 let titles = t_misty_blue::titles();
24 let theme = t_misty_blue::full();
25 let blocks_top = vec![
26 GradientBlock::new()
27 .title(titles.up.0, titles.up.1)
28 .with_gradient(theme.up)
29 .with_set(set.clone()),
30 GradientBlock::new()
31 .title(titles.down.0, titles.down.1)
32 .with_gradient(theme.down)
33 .with_set(set.clone()),
34 GradientBlock::new()
35 .title(titles.left.0, titles.left.1)
36 .with_gradient(theme.left)
37 .with_set(set.clone()),
38 GradientBlock::new()
39 .title(titles.right.0, titles.right.1)
40 .with_gradient(theme.right)
41 .with_set(set.clone()),
42 GradientBlock::new()
43 .title(titles.top_left.0, titles.top_left.1)
44 .with_gradient(theme.top_left)
45 .with_set(set.clone()),
46 GradientBlock::new()
47 .title(titles.top_right.0, titles.top_right.1)
48 .with_gradient(theme.top_right)
49 .with_set(set.clone()),
50 GradientBlock::new()
51 .title(titles.bottom_left.0, titles.bottom_left.1)
52 .with_gradient(theme.bottom_left)
53 .with_set(set.clone()),
54 ];
55 let blocks_bottom = vec![
56 GradientBlock::new()
57 .title(titles.bottom_right.0, titles.bottom_right.1)
58 .with_gradient(theme.bottom_right)
59 .with_set(set.clone()),
60 GradientBlock::new()
61 .title(
62 titles.double_corners_left.0,
63 titles.double_corners_left.1,
64 )
65 .with_gradient(theme.double_corners_left)
66 .with_set(set.clone()),
67 GradientBlock::new()
68 .title(
69 titles.double_corners_right.0,
70 titles.double_corners_right.1,
71 )
72 .with_gradient(theme.double_corners_right)
73 .with_set(set.clone()),
74 GradientBlock::new()
75 .title(titles.vertical.0, titles.vertical.1)
76 .with_gradient(theme.vertical)
77 .with_set(set.clone()),
78 GradientBlock::new()
79 .title(titles.horizontal.0, titles.horizontal.1)
80 .with_gradient(theme.horizontal)
81 .with_set(set.clone()),
82 GradientBlock::new()
83 .title(titles.misc1.0, titles.misc1.1)
84 .with_gradient(theme.misc1)
85 .with_set(set.clone()),
86 GradientBlock::new()
87 .title(titles.misc2.0, titles.misc2.1)
88 .with_gradient(theme.misc2)
89 .with_set(set.clone()),
90 ];
91
92 loop {
93 terminal.draw(|f| {
94 let base = Layout::new(
95 Direction::Vertical,
96 [
97 Constraint::Percentage(50),
98 Constraint::Percentage(50),
99 ],
100 )
101 .split(f.area());
102 let top = Layout::new(
103 Direction::Horizontal,
104 [
105 Constraint::Percentage(14),
106 Constraint::Percentage(14),
107 Constraint::Percentage(14),
108 Constraint::Percentage(14),
109 Constraint::Percentage(14),
110 Constraint::Percentage(15),
111 Constraint::Percentage(15),
112 ],
113 )
114 .split(base[0]);
115 let bottom = Layout::new(
116 Direction::Horizontal,
117 [
118 Constraint::Percentage(14),
119 Constraint::Percentage(14),
120 Constraint::Percentage(14),
121 Constraint::Percentage(14),
122 Constraint::Percentage(14),
123 Constraint::Percentage(15),
124 Constraint::Percentage(15),
125 ],
126 )
127 .split(base[1]);
128 for (block, area) in blocks_top.iter().zip(top.iter()) {
129 f.render_widget(block, *area);
130 }
131 for (block, area) in
132 blocks_bottom.iter().zip(bottom.iter())
133 {
134 f.render_widget(block, *area);
135 }
136 })?;
137 let event = event::read()?;
138
139 if let Event::Key(key_event) = event {
140 if key_event.kind == KeyEventKind::Press {
141 if let KeyCode::Char('q') = key_event.code {
142 break Ok(());
143 }
144 }
145 }
146 }
147}14fn run(
15 terminal: &mut ratatui::DefaultTerminal,
16 set: SegmentSet,
17) -> io::Result<()> {
18 use ratatui::layout::{Constraint, Direction, Layout};
19 use tui_gradient_block::{
20 gradient_block::GradientBlock,
21 theme_presets::misc::t_monochrome,
22 };
23 let titles = t_monochrome::titles();
24 let theme = t_monochrome::full();
25 let blocks_top = vec![
26 GradientBlock::new()
27 .title(titles.up.0, titles.up.1)
28 .with_gradient(theme.up)
29 .with_set(set.clone()),
30 GradientBlock::new()
31 .title(titles.down.0, titles.down.1)
32 .with_gradient(theme.down)
33 .with_set(set.clone()),
34 GradientBlock::new()
35 .title(titles.left.0, titles.left.1)
36 .with_gradient(theme.left)
37 .with_set(set.clone()),
38 GradientBlock::new()
39 .title(titles.right.0, titles.right.1)
40 .with_gradient(theme.right)
41 .with_set(set.clone()),
42 GradientBlock::new()
43 .title(titles.top_left.0, titles.top_left.1)
44 .with_gradient(theme.top_left)
45 .with_set(set.clone()),
46 GradientBlock::new()
47 .title(titles.top_right.0, titles.top_right.1)
48 .with_gradient(theme.top_right)
49 .with_set(set.clone()),
50 GradientBlock::new()
51 .title(titles.bottom_left.0, titles.bottom_left.1)
52 .with_gradient(theme.bottom_left)
53 .with_set(set.clone()),
54 ];
55 let blocks_bottom = vec![
56 GradientBlock::new()
57 .title(titles.bottom_right.0, titles.bottom_right.1)
58 .with_gradient(theme.bottom_right)
59 .with_set(set.clone()),
60 GradientBlock::new()
61 .title(
62 titles.double_corners_left.0,
63 titles.double_corners_left.1,
64 )
65 .with_gradient(theme.double_corners_left)
66 .with_set(set.clone()),
67 GradientBlock::new()
68 .title(
69 titles.double_corners_right.0,
70 titles.double_corners_right.1,
71 )
72 .with_gradient(theme.double_corners_right)
73 .with_set(set.clone()),
74 GradientBlock::new()
75 .title(titles.vertical.0, titles.vertical.1)
76 .with_gradient(theme.vertical)
77 .with_set(set.clone()),
78 GradientBlock::new()
79 .title(titles.horizontal.0, titles.horizontal.1)
80 .with_gradient(theme.horizontal)
81 .with_set(set.clone()),
82 GradientBlock::new()
83 .title(titles.misc1.0, titles.misc1.1)
84 .with_gradient(theme.misc1)
85 .with_set(set.clone()),
86 GradientBlock::new()
87 .title(titles.misc2.0, titles.misc2.1)
88 .with_gradient(theme.misc2)
89 .with_set(set.clone()),
90 ];
91
92 loop {
93 terminal.draw(|f| {
94 let base = Layout::new(
95 Direction::Vertical,
96 [
97 Constraint::Percentage(50),
98 Constraint::Percentage(50),
99 ],
100 )
101 .split(f.area());
102 let top = Layout::new(
103 Direction::Horizontal,
104 [
105 Constraint::Percentage(14),
106 Constraint::Percentage(14),
107 Constraint::Percentage(14),
108 Constraint::Percentage(14),
109 Constraint::Percentage(14),
110 Constraint::Percentage(15),
111 Constraint::Percentage(15),
112 ],
113 )
114 .split(base[0]);
115 let bottom = Layout::new(
116 Direction::Horizontal,
117 [
118 Constraint::Percentage(14),
119 Constraint::Percentage(14),
120 Constraint::Percentage(14),
121 Constraint::Percentage(14),
122 Constraint::Percentage(14),
123 Constraint::Percentage(15),
124 Constraint::Percentage(15),
125 ],
126 )
127 .split(base[1]);
128 for (block, area) in blocks_top.iter().zip(top.iter()) {
129 f.render_widget(block, *area);
130 }
131 for (block, area) in
132 blocks_bottom.iter().zip(bottom.iter())
133 {
134 f.render_widget(block, *area);
135 }
136 })?;
137 let event = event::read()?;
138
139 if let Event::Key(key_event) = event {
140 if key_event.kind == KeyEventKind::Press {
141 if let KeyCode::Char('q') = key_event.code {
142 break Ok(());
143 }
144 }
145 }
146 }
147}14fn run(
15 terminal: &mut ratatui::DefaultTerminal,
16 set: SegmentSet,
17) -> io::Result<()> {
18 use ratatui::layout::{Constraint, Direction, Layout};
19 use tui_gradient_block::{
20 gradient_block::GradientBlock,
21 theme_presets::cool::t_minty_green,
22 };
23 let titles = t_minty_green::titles();
24 let theme = t_minty_green::full();
25 let blocks_top = vec![
26 GradientBlock::new()
27 .title(titles.up.0, titles.up.1)
28 .with_gradient(theme.up)
29 .with_set(set.clone()),
30 GradientBlock::new()
31 .title(titles.down.0, titles.down.1)
32 .with_gradient(theme.down)
33 .with_set(set.clone()),
34 GradientBlock::new()
35 .title(titles.left.0, titles.left.1)
36 .with_gradient(theme.left)
37 .with_set(set.clone()),
38 GradientBlock::new()
39 .title(titles.right.0, titles.right.1)
40 .with_gradient(theme.right)
41 .with_set(set.clone()),
42 GradientBlock::new()
43 .title(titles.top_left.0, titles.top_left.1)
44 .with_gradient(theme.top_left)
45 .with_set(set.clone()),
46 GradientBlock::new()
47 .title(titles.top_right.0, titles.top_right.1)
48 .with_gradient(theme.top_right)
49 .with_set(set.clone()),
50 GradientBlock::new()
51 .title(titles.bottom_left.0, titles.bottom_left.1)
52 .with_gradient(theme.bottom_left)
53 .with_set(set.clone()),
54 ];
55 let blocks_bottom = vec![
56 GradientBlock::new()
57 .title(titles.bottom_right.0, titles.bottom_right.1)
58 .with_gradient(theme.bottom_right)
59 .with_set(set.clone()),
60 GradientBlock::new()
61 .title(
62 titles.double_corners_left.0,
63 titles.double_corners_left.1,
64 )
65 .with_gradient(theme.double_corners_left)
66 .with_set(set.clone()),
67 GradientBlock::new()
68 .title(
69 titles.double_corners_right.0,
70 titles.double_corners_right.1,
71 )
72 .with_gradient(theme.double_corners_right)
73 .with_set(set.clone()),
74 GradientBlock::new()
75 .title(titles.vertical.0, titles.vertical.1)
76 .with_gradient(theme.vertical)
77 .with_set(set.clone()),
78 GradientBlock::new()
79 .title(titles.horizontal.0, titles.horizontal.1)
80 .with_gradient(theme.horizontal)
81 .with_set(set.clone()),
82 GradientBlock::new()
83 .title(titles.misc1.0, titles.misc1.1)
84 .with_gradient(theme.misc1)
85 .with_set(set.clone()),
86 GradientBlock::new()
87 .title(titles.misc2.0, titles.misc2.1)
88 .with_gradient(theme.misc2)
89 .with_set(set.clone()),
90 ];
91
92 loop {
93 terminal.draw(|f| {
94 let base = Layout::new(
95 Direction::Vertical,
96 [
97 Constraint::Percentage(50),
98 Constraint::Percentage(50),
99 ],
100 )
101 .split(f.area());
102 let top = Layout::new(
103 Direction::Horizontal,
104 [
105 Constraint::Percentage(14),
106 Constraint::Percentage(14),
107 Constraint::Percentage(14),
108 Constraint::Percentage(14),
109 Constraint::Percentage(14),
110 Constraint::Percentage(15),
111 Constraint::Percentage(15),
112 ],
113 )
114 .split(base[0]);
115 let bottom = Layout::new(
116 Direction::Horizontal,
117 [
118 Constraint::Percentage(14),
119 Constraint::Percentage(14),
120 Constraint::Percentage(14),
121 Constraint::Percentage(14),
122 Constraint::Percentage(14),
123 Constraint::Percentage(15),
124 Constraint::Percentage(15),
125 ],
126 )
127 .split(base[1]);
128 for (block, area) in blocks_top.iter().zip(top.iter()) {
129 f.render_widget(block, *area);
130 }
131 for (block, area) in
132 blocks_bottom.iter().zip(bottom.iter())
133 {
134 f.render_widget(block, *area);
135 }
136 })?;
137 let event = event::read()?;
138
139 if let Event::Key(key_event) = event {
140 if key_event.kind == KeyEventKind::Press {
141 if let KeyCode::Char('q') = key_event.code {
142 break Ok(());
143 }
144 }
145 }
146 }
147}14fn run(
15 terminal: &mut ratatui::DefaultTerminal,
16 set: SegmentSet,
17) -> io::Result<()> {
18 use ratatui::layout::{Constraint, Direction, Layout};
19 use tui_gradient_block::{
20 gradient_block::GradientBlock,
21 theme_presets::warm::t_rusty_ruins,
22 };
23 let titles = t_rusty_ruins::titles();
24 let theme = t_rusty_ruins::full();
25 let blocks_top = vec![
26 GradientBlock::new()
27 .title(titles.up.0, titles.up.1)
28 .with_gradient(theme.up)
29 .with_set(set.clone()),
30 GradientBlock::new()
31 .title(titles.down.0, titles.down.1)
32 .with_gradient(theme.down)
33 .with_set(set.clone()),
34 GradientBlock::new()
35 .title(titles.left.0, titles.left.1)
36 .with_gradient(theme.left)
37 .with_set(set.clone()),
38 GradientBlock::new()
39 .title(titles.right.0, titles.right.1)
40 .with_gradient(theme.right)
41 .with_set(set.clone()),
42 GradientBlock::new()
43 .title(titles.top_left.0, titles.top_left.1)
44 .with_gradient(theme.top_left)
45 .with_set(set.clone()),
46 GradientBlock::new()
47 .title(titles.top_right.0, titles.top_right.1)
48 .with_gradient(theme.top_right)
49 .with_set(set.clone()),
50 GradientBlock::new()
51 .title(titles.bottom_left.0, titles.bottom_left.1)
52 .with_gradient(theme.bottom_left)
53 .with_set(set.clone()),
54 ];
55 let blocks_bottom = vec![
56 GradientBlock::new()
57 .title(titles.bottom_right.0, titles.bottom_right.1)
58 .with_gradient(theme.bottom_right)
59 .with_set(set.clone()),
60 GradientBlock::new()
61 .title(
62 titles.double_corners_left.0,
63 titles.double_corners_left.1,
64 )
65 .with_gradient(theme.double_corners_left)
66 .with_set(set.clone()),
67 GradientBlock::new()
68 .title(
69 titles.double_corners_right.0,
70 titles.double_corners_right.1,
71 )
72 .with_gradient(theme.double_corners_right)
73 .with_set(set.clone()),
74 GradientBlock::new()
75 .title(titles.vertical.0, titles.vertical.1)
76 .with_gradient(theme.vertical)
77 .with_set(set.clone()),
78 GradientBlock::new()
79 .title(titles.horizontal.0, titles.horizontal.1)
80 .with_gradient(theme.horizontal)
81 .with_set(set.clone()),
82 GradientBlock::new()
83 .title(titles.misc1.0, titles.misc1.1)
84 .with_gradient(theme.misc1)
85 .with_set(set.clone()),
86 GradientBlock::new()
87 .title(titles.misc2.0, titles.misc2.1)
88 .with_gradient(theme.misc2)
89 .with_set(set.clone()),
90 ];
91
92 loop {
93 terminal.draw(|f| {
94 let base = Layout::new(
95 Direction::Vertical,
96 [
97 Constraint::Percentage(50),
98 Constraint::Percentage(50),
99 ],
100 )
101 .split(f.area());
102 let top = Layout::new(
103 Direction::Horizontal,
104 [
105 Constraint::Percentage(14),
106 Constraint::Percentage(14),
107 Constraint::Percentage(14),
108 Constraint::Percentage(14),
109 Constraint::Percentage(14),
110 Constraint::Percentage(15),
111 Constraint::Percentage(15),
112 ],
113 )
114 .split(base[0]);
115 let bottom = Layout::new(
116 Direction::Horizontal,
117 [
118 Constraint::Percentage(14),
119 Constraint::Percentage(14),
120 Constraint::Percentage(14),
121 Constraint::Percentage(14),
122 Constraint::Percentage(14),
123 Constraint::Percentage(15),
124 Constraint::Percentage(15),
125 ],
126 )
127 .split(base[1]);
128 for (block, area) in blocks_top.iter().zip(top.iter()) {
129 f.render_widget(block, *area);
130 }
131 for (block, area) in
132 blocks_bottom.iter().zip(bottom.iter())
133 {
134 f.render_widget(block, *area);
135 }
136 })?;
137 let event = event::read()?;
138
139 if let Event::Key(key_event) = event {
140 if key_event.kind == KeyEventKind::Press {
141 if let KeyCode::Char('q') = key_event.code {
142 break Ok(());
143 }
144 }
145 }
146 }
147}Sourcepub const fn bottom_vertical_left_symbol(self, symb: char) -> Self
pub const fn bottom_vertical_left_symbol(self, symb: char) -> Self
Sets the symbol for the bottom vertical left connector.
§Example
let block = GradientBlock::new().bottom_vertical_left_symbol('|');pub fn fill<L: Into<Line<'a>>>(self, fill: L) -> Self
Sourcepub fn fill_gradient<GR: Gradient>(self, gradient: GR) -> Self
pub fn fill_gradient<GR: Gradient>(self, gradient: GR) -> Self
Sets the fill gradient
§Example
let block = GradientBlock::new().fill_gradient(colorgrad::preset::warm());Trait Implementations§
Source§impl Default for GradientBlock<'_>
impl Default for GradientBlock<'_>
Source§impl Widget for GradientBlock<'_>
impl Widget for GradientBlock<'_>
Source§impl WidgetRef for GradientBlock<'_>
impl WidgetRef for GradientBlock<'_>
Source§fn render_ref(&self, area: R, buf: &mut Buffer)
fn render_ref(&self, area: R, buf: &mut Buffer)
Auto Trait Implementations§
impl<'a> Freeze for GradientBlock<'a>
impl<'a> !RefUnwindSafe for GradientBlock<'a>
impl<'a> !Send for GradientBlock<'a>
impl<'a> !Sync for GradientBlock<'a>
impl<'a> Unpin for GradientBlock<'a>
impl<'a> !UnwindSafe for GradientBlock<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more