• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use taffy::geometry::Size;
2 
3 pub struct ImageContext {
4     pub width: f32,
5     pub height: f32,
6 }
7 
image_measure_function( known_dimensions: taffy::geometry::Size<Option<f32>>, image_context: &ImageContext, ) -> taffy::geometry::Size<f32>8 pub fn image_measure_function(
9     known_dimensions: taffy::geometry::Size<Option<f32>>,
10     image_context: &ImageContext,
11 ) -> taffy::geometry::Size<f32> {
12     match (known_dimensions.width, known_dimensions.height) {
13         (Some(width), Some(height)) => Size { width, height },
14         (Some(width), None) => Size { width, height: (width / image_context.width) * image_context.height },
15         (None, Some(height)) => Size { width: (height / image_context.height) * image_context.width, height },
16         (None, None) => Size { width: image_context.width, height: image_context.height },
17     }
18 }
19