pub struct Frame<'a> { /* private fields */ }
Expand description
A consistent view into the terminal state for rendering a single frame.
This is obtained via the closure argument of Terminal::draw
. It is used to render widgets
to the terminal and control the cursor position.
The changes drawn to the frame are applied only to the current Buffer
. After the closure
returns, the current buffer is compared to the previous buffer and only the changes are applied
to the terminal. This avoids drawing redundant cells.
Implementations§
Source§impl Frame<'_>
impl Frame<'_>
Sourcepub const fn area(&self) -> Rect
pub const fn area(&self) -> Rect
The area of the current frame
This is guaranteed not to change during rendering, so may be called multiple times.
If your app listens for a resize event from the backend, it should ignore the values from the event for any calculations that are used to render the current frame and use this value instead as this is the area of the buffer that is used to render the current frame.
Examples found in repository?
More examples
20pub fn destroy(frame: &mut Frame<'_>) {
21 let frame_count = frame.count().saturating_sub(DELAY);
22 if frame_count == 0 {
23 return;
24 }
25
26 let area = frame.area();
27 let buf = frame.buffer_mut();
28
29 drip(frame_count, area, buf);
30 text(frame_count, area, buf);
31}
- examples/constraint-explorer.rs
- examples/gauge.rs
- examples/line_gauge.rs
- examples/list.rs
- examples/table.rs
- examples/async.rs
- examples/hyperlink.rs
- examples/paragraph.rs
- examples/barchart-grouped.rs
- examples/ratatui-logo.rs
- examples/barchart.rs
- examples/custom_widget.rs
- examples/chart.rs
- examples/canvas.rs
- examples/flex.rs
- examples/calendar.rs
- examples/popup.rs
- examples/panic.rs
- examples/sparkline.rs
- examples/block.rs
- examples/inline.rs
- examples/user_input.rs
- examples/layout.rs
- examples/scrollbar.rs
Sourcepub const fn size(&self) -> Rect
👎Deprecated: use .area() as it’s the more correct name
pub const fn size(&self) -> Rect
The area of the current frame
This is guaranteed not to change during rendering, so may be called multiple times.
If your app listens for a resize event from the backend, it should ignore the values from the event for any calculations that are used to render the current frame and use this value instead as this is the area of the buffer that is used to render the current frame.
Sourcepub fn render_widget<W: Widget>(&mut self, widget: W, area: Rect)
pub fn render_widget<W: Widget>(&mut self, widget: W, area: Rect)
Render a Widget
to the current buffer using Widget::render
.
Usually the area argument is the size of the current frame or a sub-area of the current
frame (which can be obtained using Layout
to split the total area).
§Example
use ratatui::{layout::Rect, widgets::Block};
let block = Block::new();
let area = Rect::new(0, 0, 5, 5);
frame.render_widget(block, area);
Examples found in repository?
More examples
93fn render_title(frame: &mut Frame, area: Rect) {
94 frame.render_widget(
95 Paragraph::new("Block example. Press q to quit")
96 .dark_gray()
97 .alignment(Alignment::Center),
98 area,
99 );
100}
101
102fn placeholder_paragraph() -> Paragraph<'static> {
103 let text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
104 Paragraph::new(text.dark_gray()).wrap(Wrap { trim: true })
105}
106
107fn render_borders(paragraph: &Paragraph, border: Borders, frame: &mut Frame, area: Rect) {
108 let block = Block::new()
109 .borders(border)
110 .title(format!("Borders::{border:#?}"));
111 frame.render_widget(paragraph.clone().block(block), area);
112}
113
114fn render_border_type(
115 paragraph: &Paragraph,
116 border_type: BorderType,
117 frame: &mut Frame,
118 area: Rect,
119) {
120 let block = Block::bordered()
121 .border_type(border_type)
122 .title(format!("BorderType::{border_type:#?}"));
123 frame.render_widget(paragraph.clone().block(block), area);
124}
125fn render_styled_borders(paragraph: &Paragraph, frame: &mut Frame, area: Rect) {
126 let block = Block::bordered()
127 .border_style(Style::new().blue().on_white().bold().italic())
128 .title("Styled borders");
129 frame.render_widget(paragraph.clone().block(block), area);
130}
131
132fn render_styled_block(paragraph: &Paragraph, frame: &mut Frame, area: Rect) {
133 let block = Block::bordered()
134 .style(Style::new().blue().on_white().bold().italic())
135 .title("Styled block");
136 frame.render_widget(paragraph.clone().block(block), area);
137}
138
139fn render_styled_title(paragraph: &Paragraph, frame: &mut Frame, area: Rect) {
140 let block = Block::bordered()
141 .title("Styled title")
142 .title_style(Style::new().blue().on_white().bold().italic());
143 frame.render_widget(paragraph.clone().block(block), area);
144}
145
146fn render_styled_title_content(paragraph: &Paragraph, frame: &mut Frame, area: Rect) {
147 let title = Line::from(vec![
148 "Styled ".blue().on_white().bold().italic(),
149 "title content".red().on_white().bold().italic(),
150 ]);
151 let block = Block::bordered().title(title);
152 frame.render_widget(paragraph.clone().block(block), area);
153}
154
155fn render_multiple_titles(paragraph: &Paragraph, frame: &mut Frame, area: Rect) {
156 let block = Block::bordered()
157 .title("Multiple".blue().on_white().bold().italic())
158 .title("Titles".red().on_white().bold().italic());
159 frame.render_widget(paragraph.clone().block(block), area);
160}
161
162fn render_multiple_title_positions(paragraph: &Paragraph, frame: &mut Frame, area: Rect) {
163 let block = Block::bordered()
164 .title(Line::from("top left").left_aligned())
165 .title(Line::from("top center").centered())
166 .title(Line::from("top right").right_aligned())
167 .title_bottom(Line::from("bottom left").left_aligned())
168 .title_bottom(Line::from("bottom center").centered())
169 .title_bottom(Line::from("bottom right").right_aligned());
170 frame.render_widget(paragraph.clone().block(block), area);
171}
172
173fn render_padding(paragraph: &Paragraph, frame: &mut Frame, area: Rect) {
174 let block = Block::bordered()
175 .padding(Padding::new(5, 10, 1, 2))
176 .title("Padding");
177 frame.render_widget(paragraph.clone().block(block), area);
178}
179
180fn render_nested_blocks(paragraph: &Paragraph, frame: &mut Frame, area: Rect) {
181 let outer_block = Block::bordered().title("Outer block");
182 let inner_block = Block::bordered().title("Inner block");
183 let inner = outer_block.inner(area);
184 frame.render_widget(outer_block, area);
185 frame.render_widget(paragraph.clone().block(inner_block), inner);
186}
- examples/constraint-explorer.rs
- examples/gauge.rs
- examples/line_gauge.rs
- examples/list.rs
- examples/async.rs
- examples/hyperlink.rs
- examples/paragraph.rs
- examples/barchart-grouped.rs
- examples/ratatui-logo.rs
- examples/barchart.rs
- examples/custom_widget.rs
- examples/table.rs
- examples/canvas.rs
- examples/flex.rs
- examples/calendar.rs
- examples/popup.rs
- examples/panic.rs
- examples/sparkline.rs
- examples/chart.rs
- examples/inline.rs
- examples/user_input.rs
- examples/layout.rs
- examples/scrollbar.rs
Sourcepub fn render_widget_ref<W: WidgetRef>(&mut self, widget: W, area: Rect)
Available on crate feature unstable-widget-ref
only.
pub fn render_widget_ref<W: WidgetRef>(&mut self, widget: W, area: Rect)
unstable-widget-ref
only.Render a WidgetRef
to the current buffer using WidgetRef::render_ref
.
Usually the area argument is the size of the current frame or a sub-area of the current
frame (which can be obtained using [Layout
] to split the total area).
§Example
use ratatui::{layout::Rect, widgets::Block};
let block = Block::new();
let area = Rect::new(0, 0, 5, 5);
frame.render_widget_ref(block, area);
§Availability
This API is marked as unstable and is only available when the unstable-widget-ref
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn render_stateful_widget<W>(
&mut self,
widget: W,
area: Rect,
state: &mut W::State,
)where
W: StatefulWidget,
pub fn render_stateful_widget<W>(
&mut self,
widget: W,
area: Rect,
state: &mut W::State,
)where
W: StatefulWidget,
Render a StatefulWidget
to the current buffer using StatefulWidget::render
.
Usually the area argument is the size of the current frame or a sub-area of the current
frame (which can be obtained using Layout
to split the total area).
The last argument should be an instance of the StatefulWidget::State
associated to the
given StatefulWidget
.
§Example
use ratatui::{
layout::Rect,
widgets::{List, ListItem, ListState},
};
let mut state = ListState::default().with_selected(Some(1));
let list = List::new(vec![ListItem::new("Item 1"), ListItem::new("Item 2")]);
let area = Rect::new(0, 0, 5, 5);
frame.render_stateful_widget(list, area, &mut state);
Examples found in repository?
214 fn render_table(&mut self, frame: &mut Frame, area: Rect) {
215 let header_style = Style::default()
216 .fg(self.colors.header_fg)
217 .bg(self.colors.header_bg);
218 let selected_row_style = Style::default()
219 .add_modifier(Modifier::REVERSED)
220 .fg(self.colors.selected_row_style_fg);
221 let selected_col_style = Style::default().fg(self.colors.selected_column_style_fg);
222 let selected_cell_style = Style::default()
223 .add_modifier(Modifier::REVERSED)
224 .fg(self.colors.selected_cell_style_fg);
225
226 let header = ["Name", "Address", "Email"]
227 .into_iter()
228 .map(Cell::from)
229 .collect::<Row>()
230 .style(header_style)
231 .height(1);
232 let rows = self.items.iter().enumerate().map(|(i, data)| {
233 let color = match i % 2 {
234 0 => self.colors.normal_row_color,
235 _ => self.colors.alt_row_color,
236 };
237 let item = data.ref_array();
238 item.into_iter()
239 .map(|content| Cell::from(Text::from(format!("\n{content}\n"))))
240 .collect::<Row>()
241 .style(Style::new().fg(self.colors.row_fg).bg(color))
242 .height(4)
243 });
244 let bar = " █ ";
245 let t = Table::new(
246 rows,
247 [
248 // + 1 is for padding.
249 Constraint::Length(self.longest_item_lens.0 + 1),
250 Constraint::Min(self.longest_item_lens.1 + 1),
251 Constraint::Min(self.longest_item_lens.2),
252 ],
253 )
254 .header(header)
255 .row_highlight_style(selected_row_style)
256 .column_highlight_style(selected_col_style)
257 .cell_highlight_style(selected_cell_style)
258 .highlight_symbol(Text::from(vec![
259 "".into(),
260 bar.into(),
261 bar.into(),
262 "".into(),
263 ]))
264 .bg(self.colors.buffer_bg)
265 .highlight_spacing(HighlightSpacing::Always);
266 frame.render_stateful_widget(t, area, &mut self.state);
267 }
268
269 fn render_scrollbar(&mut self, frame: &mut Frame, area: Rect) {
270 frame.render_stateful_widget(
271 Scrollbar::default()
272 .orientation(ScrollbarOrientation::VerticalRight)
273 .begin_symbol(None)
274 .end_symbol(None),
275 area.inner(Margin {
276 vertical: 1,
277 horizontal: 1,
278 }),
279 &mut self.scroll_state,
280 );
281 }
More examples
92 fn draw(&mut self, frame: &mut Frame) {
93 let area = frame.area();
94
95 // Words made "loooong" to demonstrate line breaking.
96 let s =
97 "Veeeeeeeeeeeeeeeery loooooooooooooooooong striiiiiiiiiiiiiiiiiiiiiiiiiing. ";
98 let mut long_line = s.repeat(usize::from(area.width) / s.len() + 4);
99 long_line.push('\n');
100
101 let chunks = Layout::vertical([
102 Constraint::Min(1),
103 Constraint::Percentage(25),
104 Constraint::Percentage(25),
105 Constraint::Percentage(25),
106 Constraint::Percentage(25),
107 ])
108 .split(area);
109
110 let text = vec![
111 Line::from("This is a line "),
112 Line::from("This is a line ".red()),
113 Line::from("This is a line".on_dark_gray()),
114 Line::from("This is a longer line".crossed_out()),
115 Line::from(long_line.clone()),
116 Line::from("This is a line".reset()),
117 Line::from(vec![
118 Span::raw("Masked text: "),
119 Span::styled(Masked::new("password", '*'), Style::new().fg(Color::Red)),
120 ]),
121 Line::from("This is a line "),
122 Line::from("This is a line ".red()),
123 Line::from("This is a line".on_dark_gray()),
124 Line::from("This is a longer line".crossed_out()),
125 Line::from(long_line.clone()),
126 Line::from("This is a line".reset()),
127 Line::from(vec![
128 Span::raw("Masked text: "),
129 Span::styled(Masked::new("password", '*'), Style::new().fg(Color::Red)),
130 ]),
131 ];
132 self.vertical_scroll_state = self.vertical_scroll_state.content_length(text.len());
133 self.horizontal_scroll_state = self.horizontal_scroll_state.content_length(long_line.len());
134
135 let create_block = |title: &'static str| Block::bordered().gray().title(title.bold());
136
137 let title = Block::new()
138 .title_alignment(Alignment::Center)
139 .title("Use h j k l or ◄ ▲ ▼ ► to scroll ".bold());
140 frame.render_widget(title, chunks[0]);
141
142 let paragraph = Paragraph::new(text.clone())
143 .gray()
144 .block(create_block("Vertical scrollbar with arrows"))
145 .scroll((self.vertical_scroll as u16, 0));
146 frame.render_widget(paragraph, chunks[1]);
147 frame.render_stateful_widget(
148 Scrollbar::new(ScrollbarOrientation::VerticalRight)
149 .begin_symbol(Some("↑"))
150 .end_symbol(Some("↓")),
151 chunks[1],
152 &mut self.vertical_scroll_state,
153 );
154
155 let paragraph = Paragraph::new(text.clone())
156 .gray()
157 .block(create_block(
158 "Vertical scrollbar without arrows, without track symbol and mirrored",
159 ))
160 .scroll((self.vertical_scroll as u16, 0));
161 frame.render_widget(paragraph, chunks[2]);
162 frame.render_stateful_widget(
163 Scrollbar::new(ScrollbarOrientation::VerticalLeft)
164 .symbols(scrollbar::VERTICAL)
165 .begin_symbol(None)
166 .track_symbol(None)
167 .end_symbol(None),
168 chunks[2].inner(Margin {
169 vertical: 1,
170 horizontal: 0,
171 }),
172 &mut self.vertical_scroll_state,
173 );
174
175 let paragraph = Paragraph::new(text.clone())
176 .gray()
177 .block(create_block(
178 "Horizontal scrollbar with only begin arrow & custom thumb symbol",
179 ))
180 .scroll((0, self.horizontal_scroll as u16));
181 frame.render_widget(paragraph, chunks[3]);
182 frame.render_stateful_widget(
183 Scrollbar::new(ScrollbarOrientation::HorizontalBottom)
184 .thumb_symbol("🬋")
185 .end_symbol(None),
186 chunks[3].inner(Margin {
187 vertical: 0,
188 horizontal: 1,
189 }),
190 &mut self.horizontal_scroll_state,
191 );
192
193 let paragraph = Paragraph::new(text.clone())
194 .gray()
195 .block(create_block(
196 "Horizontal scrollbar without arrows & custom thumb and track symbol",
197 ))
198 .scroll((0, self.horizontal_scroll as u16));
199 frame.render_widget(paragraph, chunks[4]);
200 frame.render_stateful_widget(
201 Scrollbar::new(ScrollbarOrientation::HorizontalBottom)
202 .thumb_symbol("░")
203 .track_symbol(Some("─")),
204 chunks[4].inner(Margin {
205 vertical: 0,
206 horizontal: 1,
207 }),
208 &mut self.horizontal_scroll_state,
209 );
210 }
Sourcepub fn render_stateful_widget_ref<W>(
&mut self,
widget: W,
area: Rect,
state: &mut W::State,
)where
W: StatefulWidgetRef,
Available on crate feature unstable-widget-ref
only.
pub fn render_stateful_widget_ref<W>(
&mut self,
widget: W,
area: Rect,
state: &mut W::State,
)where
W: StatefulWidgetRef,
unstable-widget-ref
only.Render a StatefulWidgetRef
to the current buffer using
StatefulWidgetRef::render_ref
.
Usually the area argument is the size of the current frame or a sub-area of the current
frame (which can be obtained using [Layout
] to split the total area).
The last argument should be an instance of the StatefulWidgetRef::State
associated to
the given StatefulWidgetRef
.
§Example
use ratatui::{
layout::Rect,
widgets::{List, ListItem, ListState},
};
let mut state = ListState::default().with_selected(Some(1));
let list = List::new(vec![ListItem::new("Item 1"), ListItem::new("Item 2")]);
let area = Rect::new(0, 0, 5, 5);
frame.render_stateful_widget_ref(list, area, &mut state);
§Availability
This API is marked as unstable and is only available when the unstable-widget-ref
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn set_cursor_position<P: Into<Position>>(&mut self, position: P)
pub fn set_cursor_position<P: Into<Position>>(&mut self, position: P)
After drawing this frame, make the cursor visible and put it at the specified (x, y) coordinates. If this method is not called, the cursor will be hidden.
Note that this will interfere with calls to Terminal::hide_cursor
,
Terminal::show_cursor
, and Terminal::set_cursor_position
. Pick one of the APIs and
stick with it.
Examples found in repository?
169 fn draw(&self, frame: &mut Frame) {
170 let vertical = Layout::vertical([
171 Constraint::Length(1),
172 Constraint::Length(3),
173 Constraint::Min(1),
174 ]);
175 let [help_area, input_area, messages_area] = vertical.areas(frame.area());
176
177 let (msg, style) = match self.input_mode {
178 InputMode::Normal => (
179 vec![
180 "Press ".into(),
181 "q".bold(),
182 " to exit, ".into(),
183 "e".bold(),
184 " to start editing.".bold(),
185 ],
186 Style::default().add_modifier(Modifier::RAPID_BLINK),
187 ),
188 InputMode::Editing => (
189 vec![
190 "Press ".into(),
191 "Esc".bold(),
192 " to stop editing, ".into(),
193 "Enter".bold(),
194 " to record the message".into(),
195 ],
196 Style::default(),
197 ),
198 };
199 let text = Text::from(Line::from(msg)).patch_style(style);
200 let help_message = Paragraph::new(text);
201 frame.render_widget(help_message, help_area);
202
203 let input = Paragraph::new(self.input.as_str())
204 .style(match self.input_mode {
205 InputMode::Normal => Style::default(),
206 InputMode::Editing => Style::default().fg(Color::Yellow),
207 })
208 .block(Block::bordered().title("Input"));
209 frame.render_widget(input, input_area);
210 match self.input_mode {
211 // Hide the cursor. `Frame` does this by default, so we don't need to do anything here
212 InputMode::Normal => {}
213
214 // Make the cursor visible and ask ratatui to put it at the specified coordinates after
215 // rendering
216 #[allow(clippy::cast_possible_truncation)]
217 InputMode::Editing => frame.set_cursor_position(Position::new(
218 // Draw the cursor at the current position in the input field.
219 // This position is can be controlled via the left and right arrow key
220 input_area.x + self.character_index as u16 + 1,
221 // Move one line down, from the border to the input line
222 input_area.y + 1,
223 )),
224 }
225
226 let messages: Vec<ListItem> = self
227 .messages
228 .iter()
229 .enumerate()
230 .map(|(i, m)| {
231 let content = Line::from(Span::raw(format!("{i}: {m}")));
232 ListItem::new(content)
233 })
234 .collect();
235 let messages = List::new(messages).block(Block::bordered().title("Messages"));
236 frame.render_widget(messages, messages_area);
237 }
Sourcepub fn set_cursor(&mut self, x: u16, y: u16)
👎Deprecated: the method set_cursor_position indicates more clearly what about the cursor to set
pub fn set_cursor(&mut self, x: u16, y: u16)
After drawing this frame, make the cursor visible and put it at the specified (x, y) coordinates. If this method is not called, the cursor will be hidden.
Note that this will interfere with calls to Terminal::hide_cursor
,
Terminal::show_cursor
, and Terminal::set_cursor_position
. Pick one of the APIs and
stick with it.
Sourcepub fn buffer_mut(&mut self) -> &mut Buffer
pub fn buffer_mut(&mut self) -> &mut Buffer
Gets the buffer that this Frame
draws into as a mutable reference.
Examples found in repository?
20pub fn destroy(frame: &mut Frame<'_>) {
21 let frame_count = frame.count().saturating_sub(DELAY);
22 if frame_count == 0 {
23 return;
24 }
25
26 let area = frame.area();
27 let buf = frame.buffer_mut();
28
29 drip(frame_count, area, buf);
30 text(frame_count, area, buf);
31}
Sourcepub const fn count(&self) -> usize
pub const fn count(&self) -> usize
Returns the current frame count.
This method provides access to the frame count, which is a sequence number indicating how many frames have been rendered up to (but not including) this one. It can be used for purposes such as animation, performance tracking, or debugging.
Each time a frame has been rendered, this count is incremented,
providing a consistent way to reference the order and number of frames processed by the
terminal. When count reaches its maximum value (usize::MAX
), it wraps around to zero.
This count is particularly useful when dealing with dynamic content or animations where the state of the display changes over time. By tracking the frame count, developers can synchronize updates or changes to the content with the rendering process.
§Examples
let current_count = frame.count();
println!("Current frame count: {}", current_count);
Examples found in repository?
20pub fn destroy(frame: &mut Frame<'_>) {
21 let frame_count = frame.count().saturating_sub(DELAY);
22 if frame_count == 0 {
23 return;
24 }
25
26 let area = frame.area();
27 let buf = frame.buffer_mut();
28
29 drip(frame_count, area, buf);
30 text(frame_count, area, buf);
31}
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Frame<'a>
impl<'a> RefUnwindSafe for Frame<'a>
impl<'a> Send for Frame<'a>
impl<'a> Sync for Frame<'a>
impl<'a> Unpin for Frame<'a>
impl<'a> !UnwindSafe for Frame<'a>
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters
when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self
into C
, using the provided parameters.Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle
.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other
into Self
, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T
.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters
when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self
into C
, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
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 moreSource§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self
into T
, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors
fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds
error is returned which contains
the unclamped color. Read more