Skip to main content

Module image_compare

Module image_compare 

Source
Available on crate feature image-compare only.
Expand description

Two images of the same scene compared in one view, such as a screen before and after a change: side by side, one blended over the other, or split by a divider that is dragged across. Outlines can mark regions of either image, given in the image’s own pixels.

The app owns the mode, the divider position and the overlay opacity. Pointer positions come back in image pixels too, so an app can hit test what it drew.

Images are drawn from an image::Handle. Handles built from pixels with image::Handle::from_rgba work as they are; to show PNG or JPEG files, enable iced’s image feature in your app.

Re-exports§

pub use crate::theme::Tone;

Structs§

Frames
Where each image is drawn. before is None when both images share the after frame or there is no before image.
ImageCompare
An image compare builder. Convert it into an Element to render.
Outline
A rectangle drawn over the images, in image pixels.
Style
Colours of an image compare.

Enums§

Action
What an image compare shortcut does to the divider.
Mode
How the two images are shown.
Status
How the pointer is interacting with the divider.

Constants§

GRAB
How close to the divider a mouse press grabs it, in logical pixels.
HANDLE_RADIUS
Radius of the divider’s handle.
STEP
How far a step action moves the divider, as a fraction of the width.
TOUCH_GRAB
How close to the divider a finger grabs it.

Functions§

default_keymap
The default image compare shortcuts:
divider_at
The divider position for a pointer at x over frame.
fit
Where an image of image size is drawn inside area: as large as fits, keeping its shape, centred.
frames
The frames for mode inside bounds. Side by side, the images split the width with gap between them; None is a single image.
from_image
A rectangle in image pixels, on screen inside frame.
image_compare
Compares before with after, in Mode::Slider with the divider in the middle.
natural_height
The height the frames need at width, keeping the images’ shape.
outline_colours
An outline’s line in its tone, and the contrasting halo either side of it, so it shows over light and dark images in either theme.
single
Shows one image, with outlines and pointer reports but no divider.
style
Resolves the colours of an image compare for the divider’s status.
to_image
The image pixel under position, or None outside the frame.