pub struct KittyImageRenderer { /* private fields */ }
Expand description

The image renderer, with knowledge of the console cells dimensions, and built only on a compatible terminal

Implementations§

Called only once (at most) by the KittyManager

Examples found in repository?
src/kitty/mod.rs (line 75)
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
    pub fn renderer(&mut self) -> Option<&mut KittyImageRenderer> {
        if matches!(self.renderer, MaybeRenderer::Disabled) {
            return None;
        }
        if matches!(self.renderer, MaybeRenderer::Enabled { .. }) {
            return self.renderer_if_tested();
        }
        // we're in the Untested branch
        match KittyImageRenderer::new() {
            Some(renderer) => {
                self.renderer = MaybeRenderer::Enabled { renderer };
                self.renderer_if_tested()
            }
            None => {
                self.renderer = MaybeRenderer::Disabled;
                None
            }
        }
    }

Clean the area, then print the dynamicImage and return the KittyImageId for later removal from screen

Examples found in repository?
src/kitty/mod.rs (line 106)
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
    pub fn try_print_image(
        &mut self,
        w: &mut W,
        src: &DynamicImage,
        area: &Area,
        bg: Color,
        drawing_count: usize,
    ) -> Result<Option<KittyImageId>, ProgramError> {
        if let Some(renderer) = self.renderer() {
            let new_id = renderer.print(w, src, area, bg)?;
            self.rendered_images.push(RenderedImage {
                image_id: new_id,
                drawing_count,
            });
            Ok(Some(new_id))
        } else {
            Ok(None)
        }
    }

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.