pub fn affine_to_fill(self, parent: Size, fit_box: Size) -> Affine {
        let raw_scalex = parent.width / fit_box.width;
        let raw_scaley = parent.height / fit_box.height;

        let (scalex, scaley) = match self {
            FillStrat::Contain => {
                let scale = raw_scalex.min(raw_scaley);
                (scale, scale)
            }
            FillStrat::Cover => {
                let scale = raw_scalex.max(raw_scaley);
                (scale, scale)
            }
            FillStrat::Fill => (raw_scalex, raw_scaley),
            FillStrat::FitHeight => (raw_scaley, raw_scaley),
            FillStrat::FitWidth => (raw_scalex, raw_scalex),
            FillStrat::ScaleDown => {
                let scale = raw_scalex.min(raw_scaley).min(1.0);
                (scale, scale)
            }
            FillStrat::None => (1.0, 1.0),
        };

        let origin_x = (parent.width - (fit_box.width * scalex)) / 2.0;
        let origin_y = (parent.height - (fit_box.height * scaley)) / 2.0;

        Affine::new([scalex, 0., 0., scaley, origin_x, origin_y])
    }
/// Calculate an origin and scale for an image with a given `FillStrat`.
///
/// This takes some properties of a widget and a fill strategy and returns an affine matrix
/// used to position and scale the image in the widget.
Calculate an origin and scale for an image with a given `FillStrat`.
This takes some properties of a widget and a fill strategy and returns an affine matrix
used to position and scale the image in the widget.
Calculate an origin and scale for an image with a given ` FillStrat ` . This takes some properties of a widget and a fill strategy and returns an affine matrix used to position and scale the image in the widget .
pub fn affine_to_fill(self, parent: Size, fit_box: Size) -> Affine {
        let raw_scalex = parent.width / fit_box.width;
        let raw_scaley = parent.height / fit_box.height;
        let (scalex, scaley) = match self {
            FillStrat::Contain => {
                let scale = raw_scalex.min(raw_scaley);
                (scale, scale)
            }
            FillStrat::Cover => {
                let scale = raw_scalex.max(raw_scaley);
                (scale, scale)
            }
            FillStrat::Fill => (raw_scalex, raw_scaley),
            FillStrat::FitHeight => (raw_scaley, raw_scaley),
            FillStrat::FitWidth => (raw_scalex, raw_scalex),
            FillStrat::ScaleDown => {
                let scale = raw_scalex.min(raw_scaley).min(1.0);
                (scale, scale)
            }
            FillStrat::None => (1.0, 1.0),
        };
        let origin_x = (parent.width - (fit_box.width * scalex)) / 2.0;
        let origin_y = (parent.height - (fit_box.height * scaley)) / 2.0;
        Affine::new([scalex, 0., 0., scaley, origin_x, origin_y])
    }
pub fn affine_to_fill ( self , parent : Size , fit_box : Size ) -> Affine { let raw_scalex = parent . width / fit_box . width ; let raw_scaley = parent . height / fit_box . height ; let ( scalex , scaley ) = match self { FillStrat :: Contain => { let scale = raw_scalex . min ( raw_scaley ) ; ( scale , scale ) } FillStrat :: Cover => { let scale = raw_scalex . max ( raw_scaley ) ; ( scale , scale ) } FillStrat :: Fill => ( raw_scalex , raw_scaley ) , FillStrat :: FitHeight => ( raw_scaley , raw_scaley ) , FillStrat :: FitWidth => ( raw_scalex , raw_scalex ) , FillStrat :: ScaleDown => { let scale = raw_scalex . min ( raw_scaley ) . min ( 1.0 ) ; ( scale , scale ) } FillStrat :: None => ( 1.0 , 1.0 ) , } ; let origin_x = ( parent . width - ( fit_box . width * scalex ) ) / 2.0 ; let origin_y = ( parent . height - ( fit_box . height * scaley ) ) / 2.0 ; Affine :: new ( [ scalex , 0. , 0. , scaley , origin_x , origin_y ] ) }
Calculate an origin and scale for an image with a given `FillStrat`.
Calculate an origin and scale for an image with a given ` FillStrat ` .
self
parent
Size
fit_box
Size
self
parent
Size
fit_box
Size