pub struct Buffer {
pub area: Rect,
pub content: Vec<Cell>,
}
Expand description
A buffer that maps to the desired content of the terminal after the draw call
No widget in the library interacts directly with the terminal. Instead each of them is required to draw their state to an intermediate buffer. It is basically a grid where each cell contains a grapheme, a foreground color and a background color. This grid will then be used to output the appropriate escape sequences and characters to draw the UI as the user has defined it.
§Examples:
use ratatui::{
buffer::{Buffer, Cell},
layout::{Position, Rect},
style::{Color, Style},
};
let mut buf = Buffer::empty(Rect {
x: 0,
y: 0,
width: 10,
height: 5,
});
// indexing using Position
buf[Position { x: 0, y: 0 }].set_symbol("A");
assert_eq!(buf[Position { x: 0, y: 0 }].symbol(), "A");
// indexing using (x, y) tuple (which is converted to Position)
buf[(0, 1)].set_symbol("B");
assert_eq!(buf[(0, 1)].symbol(), "x");
// getting an Option instead of panicking if the position is outside the buffer
let cell = buf.cell_mut(Position { x: 0, y: 2 })?;
cell.set_symbol("C");
let cell = buf.cell(Position { x: 0, y: 2 })?;
assert_eq!(cell.symbol(), "C");
buf.set_string(
3,
0,
"string",
Style::default().fg(Color::Red).bg(Color::White),
);
let cell = &buf[(5, 0)]; // cannot move out of buf, so we borrow it
assert_eq!(cell.symbol(), "r");
assert_eq!(cell.fg, Color::Red);
assert_eq!(cell.bg, Color::White);
Fields§
§area: Rect
The area represented by this buffer
content: Vec<Cell>
The content of the buffer. The length of this Vec should always be equal to area.width * area.height
Implementations§
Source§impl Buffer
impl Buffer
Sourcepub fn empty(area: Rect) -> Self
pub fn empty(area: Rect) -> Self
Returns a Buffer with all cells set to the default one
Examples found in repository?
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
fn render_demo(self, area: Rect, buf: &mut Buffer) -> bool {
// render demo content into a separate buffer so all examples fit we add an extra
// area.height to make sure the last example is fully visible even when the scroll offset is
// at the max
let height = example_height();
let demo_area = Rect::new(0, 0, area.width, height);
let mut demo_buf = Buffer::empty(demo_area);
let scrollbar_needed = self.scroll_offset != 0 || height > area.height;
let content_area = if scrollbar_needed {
Rect {
width: demo_area.width - 1,
..demo_area
}
} else {
demo_area
};
let mut spacing = self.spacing;
self.selected_tab
.render(content_area, &mut demo_buf, &mut spacing);
let visible_content = demo_buf
.content
.into_iter()
.skip((area.width * self.scroll_offset) as usize)
.take(area.area() as usize);
for (i, cell) in visible_content.enumerate() {
let x = i as u16 % area.width;
let y = i as u16 / area.width;
buf[(area.x + x, area.y + y)] = cell;
}
if scrollbar_needed {
let area = area.intersection(buf.area);
let mut state = ScrollbarState::new(max_scroll_offset() as usize)
.position(self.scroll_offset as usize);
Scrollbar::new(ScrollbarOrientation::VerticalRight).render(area, buf, &mut state);
}
scrollbar_needed
}
More examples
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
fn text(frame_count: usize, area: Rect, buf: &mut Buffer) {
let sub_frame = frame_count.saturating_sub(TEXT_DELAY);
if sub_frame == 0 {
return;
}
let logo = indoc::indoc! {"
██████ ████ ██████ ████ ██████ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██████ ████████ ██ ████████ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ████ ██
"};
let logo_text = Text::styled(logo, Color::Rgb(255, 255, 255));
let area = centered_rect(area, logo_text.width() as u16, logo_text.height() as u16);
let mask_buf = &mut Buffer::empty(area);
logo_text.render(area, mask_buf);
let percentage = (sub_frame as f64 / 480.0).clamp(0.0, 1.0);
for row in area.rows() {
for col in row.columns() {
let cell = &mut buf[(col.x, col.y)];
let mask_cell = &mut mask_buf[(col.x, col.y)];
cell.set_symbol(mask_cell.symbol());
// blend the mask cell color with the cell color
let cell_color = cell.style().bg.unwrap_or(Color::Rgb(0, 0, 0));
let mask_color = mask_cell.style().fg.unwrap_or(Color::Rgb(255, 0, 0));
let color = blend(mask_color, cell_color, percentage);
cell.set_style(Style::new().fg(color));
}
}
}
Sourcepub fn filled(area: Rect, cell: Cell) -> Self
pub fn filled(area: Rect, cell: Cell) -> Self
Returns a Buffer with all cells initialized with the attributes of the given Cell
Sourcepub fn with_lines<'a, Iter>(lines: Iter) -> Self
pub fn with_lines<'a, Iter>(lines: Iter) -> Self
Returns a Buffer containing the given lines
Sourcepub fn get(&self, x: u16, y: u16) -> &Cell
👎Deprecated: Use Buffer[] or Buffer::cell instead
pub fn get(&self, x: u16, y: u16) -> &Cell
Returns a reference to the Cell
at the given coordinates
Callers should use Buffer[]
or Buffer::cell
instead of this method.
Note: idiomatically methods named get
usually return Option<&T>
, but this method panics
instead. This is kept for backwards compatibility. See cell
for a safe
alternative.
§Panics
Panics if the index is out of bounds.
Sourcepub fn get_mut(&mut self, x: u16, y: u16) -> &mut Cell
👎Deprecated: Use Buffer[] or Buffer::cell_mut instead
pub fn get_mut(&mut self, x: u16, y: u16) -> &mut Cell
Returns a mutable reference to the Cell
at the given coordinates.
Callers should use Buffer[]
or Buffer::cell_mut
instead of this
method.
Note: idiomatically methods named get_mut
usually return Option<&mut T>
, but this method
panics instead. This is kept for backwards compatibility. See cell_mut
for a safe alternative.
§Panics
Panics if the position is outside the Buffer
’s area.
Sourcepub fn cell<P: Into<Position>>(&self, position: P) -> Option<&Cell>
pub fn cell<P: Into<Position>>(&self, position: P) -> Option<&Cell>
Returns a reference to the Cell
at the given position or None
if the position is
outside the Buffer
’s area.
This method accepts any value that can be converted to Position
(e.g. (x, y)
or
Position::new(x, y)
).
For a method that panics when the position is outside the buffer instead of returning
None
, use Buffer[]
.
§Examples
use ratatui::{
buffer::{Buffer, Cell},
layout::{Position, Rect},
};
let mut buffer = Buffer::empty(Rect::new(0, 0, 10, 10));
assert_eq!(buffer.cell(Position::new(0, 0)), Some(&Cell::default()));
assert_eq!(buffer.cell(Position::new(10, 10)), None);
assert_eq!(buffer.cell((0, 0)), Some(&Cell::default()));
assert_eq!(buffer.cell((10, 10)), None);
Sourcepub fn cell_mut<P: Into<Position>>(&mut self, position: P) -> Option<&mut Cell>
pub fn cell_mut<P: Into<Position>>(&mut self, position: P) -> Option<&mut Cell>
Returns a mutable reference to the Cell
at the given position or None
if the
position is outside the Buffer
’s area.
This method accepts any value that can be converted to Position
(e.g. (x, y)
or
Position::new(x, y)
).
For a method that panics when the position is outside the buffer instead of returning
None
, use Buffer[]
.
§Examples
use ratatui::{
buffer::{Buffer, Cell},
layout::{Position, Rect},
style::{Color, Style},
};
let mut buffer = Buffer::empty(Rect::new(0, 0, 10, 10));
if let Some(cell) = buffer.cell_mut(Position::new(0, 0)) {
cell.set_symbol("A");
}
if let Some(cell) = buffer.cell_mut((0, 0)) {
cell.set_style(Style::default().fg(Color::Red));
}
Sourcepub fn index_of(&self, x: u16, y: u16) -> usize
pub fn index_of(&self, x: u16, y: u16) -> usize
Returns the index in the Vec<Cell>
for the given global (x, y) coordinates.
Global coordinates are offset by the Buffer’s area offset (x
/y
).
§Examples
use ratatui::{buffer::Buffer, layout::Rect};
let buffer = Buffer::empty(Rect::new(200, 100, 10, 10));
// Global coordinates to the top corner of this buffer's area
assert_eq!(buffer.index_of(200, 100), 0);
§Panics
Panics when given an coordinate that is outside of this Buffer’s area.
use ratatui::{buffer::Buffer, layout::Rect};
let buffer = Buffer::empty(Rect::new(200, 100, 10, 10));
// Top coordinate is outside of the buffer in global coordinate space, as the Buffer's area
// starts at (200, 100).
buffer.index_of(0, 0); // Panics
Sourcepub fn pos_of(&self, index: usize) -> (u16, u16)
pub fn pos_of(&self, index: usize) -> (u16, u16)
Returns the (global) coordinates of a cell given its index
Global coordinates are offset by the Buffer’s area offset (x
/y
).
§Examples
use ratatui::{buffer::Buffer, layout::Rect};
let rect = Rect::new(200, 100, 10, 10);
let buffer = Buffer::empty(rect);
assert_eq!(buffer.pos_of(0), (200, 100));
assert_eq!(buffer.pos_of(14), (204, 101));
§Panics
Panics when given an index that is outside the Buffer’s content.
use ratatui::{buffer::Buffer, layout::Rect};
let rect = Rect::new(0, 0, 10, 10); // 100 cells in total
let buffer = Buffer::empty(rect);
// Index 100 is the 101th cell, which lies outside of the area of this Buffer.
buffer.pos_of(100); // Panics
Sourcepub fn set_string<T, S>(&mut self, x: u16, y: u16, string: T, style: S)
pub fn set_string<T, S>(&mut self, x: u16, y: u16, string: T, style: S)
Print a string, starting at the position (x, y)
Examples found in repository?
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
fn render(self, area: Rect, buf: &mut Buffer) {
let (background, text, shadow, highlight) = self.colors();
buf.set_style(area, Style::new().bg(background).fg(text));
// render top line if there's enough space
if area.height > 2 {
buf.set_string(
area.x,
area.y,
"▔".repeat(area.width as usize),
Style::new().fg(highlight).bg(background),
);
}
// render bottom line if there's enough space
if area.height > 1 {
buf.set_string(
area.x,
area.y + area.height - 1,
"▁".repeat(area.width as usize),
Style::new().fg(shadow).bg(background),
);
}
// render label centered
buf.set_line(
area.x + (area.width.saturating_sub(self.label.width() as u16)) / 2,
area.y + (area.height.saturating_sub(1)) / 2,
&self.label,
area.width,
);
}
Sourcepub fn set_stringn<T, S>(
&mut self,
x: u16,
y: u16,
string: T,
max_width: usize,
style: S,
) -> (u16, u16)
pub fn set_stringn<T, S>( &mut self, x: u16, y: u16, string: T, max_width: usize, style: S, ) -> (u16, u16)
Print at most the first n characters of a string if enough space is available until the end of the line. Skips zero-width graphemes and control characters.
Use Buffer::set_string
when the maximum amount of characters can be printed.
Sourcepub fn set_line(
&mut self,
x: u16,
y: u16,
line: &Line<'_>,
max_width: u16,
) -> (u16, u16)
pub fn set_line( &mut self, x: u16, y: u16, line: &Line<'_>, max_width: u16, ) -> (u16, u16)
Print a line, starting at the position (x, y)
Examples found in repository?
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
fn render(self, area: Rect, buf: &mut Buffer) {
let (background, text, shadow, highlight) = self.colors();
buf.set_style(area, Style::new().bg(background).fg(text));
// render top line if there's enough space
if area.height > 2 {
buf.set_string(
area.x,
area.y,
"▔".repeat(area.width as usize),
Style::new().fg(highlight).bg(background),
);
}
// render bottom line if there's enough space
if area.height > 1 {
buf.set_string(
area.x,
area.y + area.height - 1,
"▁".repeat(area.width as usize),
Style::new().fg(shadow).bg(background),
);
}
// render label centered
buf.set_line(
area.x + (area.width.saturating_sub(self.label.width() as u16)) / 2,
area.y + (area.height.saturating_sub(1)) / 2,
&self.label,
area.width,
);
}
Sourcepub fn set_span(
&mut self,
x: u16,
y: u16,
span: &Span<'_>,
max_width: u16,
) -> (u16, u16)
pub fn set_span( &mut self, x: u16, y: u16, span: &Span<'_>, max_width: u16, ) -> (u16, u16)
Print a span, starting at the position (x, y)
Sourcepub fn set_style<S: Into<Style>>(&mut self, area: Rect, style: S)
pub fn set_style<S: Into<Style>>(&mut self, area: Rect, style: S)
Set the style of all cells in the given area.
style
accepts any type that is convertible to Style
(e.g. Style
, Color
, or
your own type that implements Into<Style>
).
Examples found in repository?
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
fn render(self, area: Rect, buf: &mut Buffer) {
let (background, text, shadow, highlight) = self.colors();
buf.set_style(area, Style::new().bg(background).fg(text));
// render top line if there's enough space
if area.height > 2 {
buf.set_string(
area.x,
area.y,
"▔".repeat(area.width as usize),
Style::new().fg(highlight).bg(background),
);
}
// render bottom line if there's enough space
if area.height > 1 {
buf.set_string(
area.x,
area.y + area.height - 1,
"▁".repeat(area.width as usize),
Style::new().fg(shadow).bg(background),
);
}
// render label centered
buf.set_line(
area.x + (area.width.saturating_sub(self.label.width() as u16)) / 2,
area.y + (area.height.saturating_sub(1)) / 2,
&self.label,
area.width,
);
}
More examples
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
fn render_4px(&self, area: Rect, buf: &mut Buffer) {
let lighter_color = ConstraintName::from(self.constraint).lighter_color();
let main_color = ConstraintName::from(self.constraint).color();
let selected_color = if self.selected {
lighter_color
} else {
main_color
};
let color = if self.legend {
selected_color
} else {
main_color
};
let label = self.label(area.width);
let block = Block::bordered()
.border_set(symbols::border::QUADRANT_OUTSIDE)
.border_style(Style::reset().fg(color).reversed())
.fg(Self::TEXT_COLOR)
.bg(color);
Paragraph::new(label)
.centered()
.fg(Self::TEXT_COLOR)
.bg(color)
.block(block)
.render(area, buf);
if !self.legend {
let border_color = if self.selected {
lighter_color
} else {
main_color
};
if let Some(last_row) = area.rows().last() {
buf.set_style(last_row, border_color);
}
}
}
Sourcepub fn resize(&mut self, area: Rect)
pub fn resize(&mut self, area: Rect)
Resize the buffer so that the mapped area matches the given area and that the buffer length is equal to area.width * area.height
Sourcepub fn diff<'a>(&self, other: &'a Self) -> Vec<(u16, u16, &'a Cell)>
pub fn diff<'a>(&self, other: &'a Self) -> Vec<(u16, u16, &'a Cell)>
Builds a minimal sequence of coordinates and Cells necessary to update the UI from self to other.
We’re assuming that buffers are well-formed, that is no double-width cell is followed by a non-blank cell.
§Multi-width characters handling:
(Index:) `01`
Prev: `コ`
Next: `aa`
Updates: `0: a, 1: a'
(Index:) `01`
Prev: `a `
Next: `コ`
Updates: `0: コ` (double width symbol at index 0 - skip index 1)
(Index:) `012`
Prev: `aaa`
Next: `aコ`
Updates: `0: a, 1: コ` (double width symbol at index 1 - skip index 2)
Trait Implementations§
Source§impl Debug for Buffer
impl Debug for Buffer
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Writes a debug representation of the buffer to the given formatter.
The format is like a pretty printed struct, with the following fields:
area
: displayed asRect { x: 1, y: 2, width: 3, height: 4 }
content
: displayed as a list of strings representing the content of the bufferstyles
: displayed as a list of:{ x: 1, y: 2, fg: Color::Red, bg: Color::Blue, modifier: Modifier::BOLD }
only showing a value when there is a change in style.
Source§impl<'de> Deserialize<'de> for Buffer
impl<'de> Deserialize<'de> for Buffer
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<P: Into<Position>> Index<P> for Buffer
impl<P: Into<Position>> Index<P> for Buffer
Source§fn index(&self, position: P) -> &Self::Output
fn index(&self, position: P) -> &Self::Output
Returns a reference to the Cell
at the given position.
This method accepts any value that can be converted to Position
(e.g. (x, y)
or
Position::new(x, y)
).
§Panics
May panic if the given position is outside the buffer’s area. For a method that returns
None
instead of panicking, use Buffer::cell
.
§Examples
use ratatui::{
buffer::{Buffer, Cell},
layout::{Position, Rect},
};
let buf = Buffer::empty(Rect::new(0, 0, 10, 10));
let cell = &buf[(0, 0)];
let cell = &buf[Position::new(0, 0)];
Source§impl<P: Into<Position>> IndexMut<P> for Buffer
impl<P: Into<Position>> IndexMut<P> for Buffer
Source§fn index_mut(&mut self, position: P) -> &mut Self::Output
fn index_mut(&mut self, position: P) -> &mut Self::Output
Returns a mutable reference to the Cell
at the given position.
This method accepts any value that can be converted to Position
(e.g. (x, y)
or
Position::new(x, y)
).
§Panics
May panic if the given position is outside the buffer’s area. For a method that returns
None
instead of panicking, use Buffer::cell_mut
.
§Examples
use ratatui::{
buffer::{Buffer, Cell},
layout::{Position, Rect},
};
let mut buf = Buffer::empty(Rect::new(0, 0, 10, 10));
buf[(0, 0)].set_symbol("A");
buf[Position::new(0, 0)].set_symbol("B");
impl Eq for Buffer
impl StructuralPartialEq for Buffer
Auto Trait Implementations§
impl Freeze for Buffer
impl RefUnwindSafe for Buffer
impl Send for Buffer
impl Sync for Buffer
impl Unpin for Buffer
impl UnwindSafe for Buffer
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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