oxipdf-ir 0.1.0

Intermediate representation types for the oxipdf PDF engine
Documentation
//! Image-specific style properties: object-fit and object-position.

use crate::units::Pt;

/// How an image's content is sized within its layout box.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum ObjectFit {
    /// Stretch to fill the box (distorts aspect ratio).
    #[default]
    Fill,
    /// Scale to fit within the box (preserves aspect ratio, may letterbox).
    Contain,
    /// Scale to cover the box (preserves aspect ratio, may crop).
    Cover,
    /// Use intrinsic size, don't scale at all.
    None,
    /// Like Contain but never enlarges (uses smaller of intrinsic or contain).
    ScaleDown,
}

/// Positioning of the image within its layout box along one axis.
#[derive(Debug, Clone, Copy, PartialEq, Default)]
pub enum ObjectPosition {
    /// Start edge (left for X, top for Y).
    #[default]
    Start,
    /// Centered.
    Center,
    /// End edge (right for X, bottom for Y).
    End,
    /// Explicit offset from start.
    Length(Pt),
}

/// Image rendering style properties.
#[derive(Debug, Clone, Copy, PartialEq, Default)]
pub struct ImageStyle {
    /// How the image content is sized within its box.
    pub object_fit: ObjectFit,
    /// Horizontal position of the image within its box.
    pub object_position_x: ObjectPosition,
    /// Vertical position of the image within its box.
    pub object_position_y: ObjectPosition,
}