Struct surf_n_term::image::Image
source · pub struct Image { /* private fields */ }
Expand description
Arc wrapped RGBA surface with precomputed hash
Implementations§
source§impl Image
impl Image
sourcepub fn new(surf: impl Surface<Item = impl Color>) -> Self
pub fn new(surf: impl Surface<Item = impl Color>) -> Self
Create new image from the RGBA surface
sourcepub fn from_parts(data: Arc<[RGBA]>, shape: Shape) -> Self
pub fn from_parts(data: Arc<[RGBA]>, shape: Shape) -> Self
Create new image from parts
sourcepub fn crop<RS, CS>(&self, rows: RS, cols: CS) -> Selfwhere
RS: ViewBounds,
CS: ViewBounds,
pub fn crop<RS, CS>(&self, rows: RS, cols: CS) -> Selfwhere
RS: ViewBounds,
CS: ViewBounds,
Crop image
sourcepub fn size_cells(&self, pixels_per_cell: Size) -> Size
pub fn size_cells(&self, pixels_per_cell: Size) -> Size
Size in cells
sourcepub fn quantize(
&self,
palette_size: usize,
dither: bool,
bg: Option<RGBA>
) -> Option<(ColorPalette, SurfaceOwned<usize>)>
pub fn quantize( &self, palette_size: usize, dither: bool, bg: Option<RGBA> ) -> Option<(ColorPalette, SurfaceOwned<usize>)>
Quantize image
Perform palette extraction and Floyd–Steinberg dithering.
sourcepub fn ascii_view(&self) -> ImageAsciiView
pub fn ascii_view(&self) -> ImageAsciiView
ASCII image view
Trait Implementations§
source§impl<'de> Deserialize<'de> for Image
impl<'de> Deserialize<'de> for Image
Image deserializer encoding is { data: base64(deflate(image)), size: Size, channels: u8 }
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>,
Deserialize this value from the given Serde deserializer. Read more
source§impl From<SurfaceOwned<RGBA>> for Image
impl From<SurfaceOwned<RGBA>> for Image
source§fn from(value: SurfaceOwned<RGBA>) -> Self
fn from(value: SurfaceOwned<RGBA>) -> Self
Converts to this type from the input type.
source§impl Ord for Image
impl Ord for Image
source§impl PartialEq for Image
impl PartialEq for Image
source§impl PartialOrd for Image
impl PartialOrd for Image
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl Surface for Image
impl Surface for Image
type Item = RGBA
fn hash(&self) -> u64
source§fn get(&self, pos: Position) -> Option<&Self::Item>
fn get(&self, pos: Position) -> Option<&Self::Item>
Get immutable reference to the element specified by row and column
source§fn iter(&self) -> SurfaceIter<'_, Self::Item> ⓘ
fn iter(&self) -> SurfaceIter<'_, Self::Item> ⓘ
Iterator over immutable references to the items of the view in the row-major order
source§fn view<RS, CS>(&self, rows: RS, cols: CS) -> SurfaceView<'_, Self::Item>
fn view<RS, CS>(&self, rows: RS, cols: CS) -> SurfaceView<'_, Self::Item>
Create an immutable sub-surface restricted by
rows
and cols
bounds.fn as_ref(&self) -> SurfaceView<'_, Self::Item>
source§fn view_owned<RS, CS>(self, rows: RS, cols: CS) -> SurfaceOwnedView<Self>
fn view_owned<RS, CS>(self, rows: RS, cols: CS) -> SurfaceOwnedView<Self>
Create owned sub-surface restricted by
rows
and cols
bounds.fn transpose(self) -> SurfaceOwnedView<Self>where
Self: Sized,
fn map<F, T>(&self, f: F) -> SurfaceOwned<T>
source§fn to_owned_surf(&self) -> SurfaceOwned<Self::Item>
fn to_owned_surf(&self) -> SurfaceOwned<Self::Item>
Create owned copy of the surface
source§impl View for Image
impl View for Image
source§fn render(
&self,
ctx: &ViewContext,
surf: TerminalSurface<'_>,
layout: ViewLayout<'_>
) -> Result<(), Error>
fn render( &self, ctx: &ViewContext, surf: TerminalSurface<'_>, layout: ViewLayout<'_> ) -> Result<(), Error>
Render view into a given surface with the provided layout
source§fn layout(
&self,
ctx: &ViewContext,
ct: BoxConstraint,
layout: ViewMutLayout<'_>
) -> Result<(), Error>
fn layout( &self, ctx: &ViewContext, ct: BoxConstraint, layout: ViewMutLayout<'_> ) -> Result<(), Error>
Compute layout of the view based on the constraints
fn layout_new<'a>( &self, ctx: &ViewContext, ct: BoxConstraint, store: &'a mut ViewLayoutStore ) -> Result<ViewMutLayout<'a>, Error>
source§fn debug(&self, size: Size) -> ViewDebug<&Self>where
Self: Sized,
fn debug(&self, size: Size) -> ViewDebug<&Self>where
Self: Sized,
Wrapper around view that implements std::fmt::Debug which renders
view. Only supposed to be used for debugging.
source§fn trace_layout<T>(self, trace: T) -> TraceLayout<Self, T>
fn trace_layout<T>(self, trace: T) -> TraceLayout<Self, T>
Wrapper around view that calls trace function on every layout call
impl Eq for Image
Auto Trait Implementations§
impl Freeze for Image
impl RefUnwindSafe for Image
impl Send for Image
impl Sync for Image
impl Unpin for Image
impl UnwindSafe for Image
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
Mutably borrows from an owned value. Read more
source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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
Compare self to
key
and return true
if they are equal.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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> ⓘ
Converts
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> ⓘ
Converts
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