Skip to main content

egui_charts/drawings/domain/
image.rs

1//! Size and opacity of the image tool's frame.
2
3use serde::{Deserialize, Serialize};
4
5/// Size and opacity of an [`Image`](crate::drawings::DrawingToolType::Image) drawing's frame.
6///
7/// The frame's top-left corner is the drawing's anchor. Its size is in points, so the
8/// picture keeps its size and proportions when the chart zooms or scrolls.
9#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
10#[serde(default)]
11#[non_exhaustive]
12pub struct ImageConfig {
13    /// Width and height of the frame in points, each from 1 to 10,000. `None` draws the
14    /// default 120 x 90 frame with the picture fitted inside it, as before frames were sized.
15    pub size: Option<[f32; 2]>,
16    /// Opacity of the picture, from 0 (hidden) to 255 (opaque). The border and the
17    /// placeholder are not affected.
18    pub opacity: u8,
19}
20
21impl Default for ImageConfig {
22    fn default() -> Self {
23        Self {
24            size: None,
25            opacity: 255,
26        }
27    }
28}