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.
beforeisNonewhen both images share theafterframe or there is no before image. - Image
Compare - An image compare builder. Convert it into an
Elementto 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
xoverframe. - fit
- Where an image of
imagesize is drawn insidearea: as large as fits, keeping its shape, centred. - frames
- The frames for
modeinsidebounds. Side by side, the images split the width withgapbetween them;Noneis a single image. - from_
image - A rectangle in image pixels, on screen inside
frame. - image_
compare - Compares
beforewithafter, inMode::Sliderwith 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, orNoneoutside the frame.