diff --git a/graphics/src/transformation.rs b/graphics/src/transformation.rs index 2a2be0bd4b..f0c97922fd 100644 --- a/graphics/src/transformation.rs +++ b/graphics/src/transformation.rs @@ -25,19 +25,15 @@ impl Transformation { Transformation(Mat4::from_translation(Vec3::new(x, y, 0.0))) } - /// Creates a scale transformation. - pub fn scale(x: f32, y: f32) -> Transformation { - Transformation(Mat4::from_scale(Vec3::new(x, y, 1.0))) + /// Creates a uniform scaling transformation. + pub fn scale(scaling: f32) -> Transformation { + Transformation(Mat4::from_scale(Vec3::new(scaling, scaling, 1.0))) } - pub fn scale_x(&self) -> f32 { + pub fn scale_factor(&self) -> f32 { self.0.x_axis.x } - pub fn scale_y(&self) -> f32 { - self.0.y_axis.y - } - pub fn translation_x(&self) -> f32 { self.0.w_axis.x } diff --git a/tiny_skia/src/backend.rs b/tiny_skia/src/backend.rs index 8d4febc307..e8f93fde6b 100644 --- a/tiny_skia/src/backend.rs +++ b/tiny_skia/src/backend.rs @@ -376,7 +376,7 @@ impl Backend { paragraph, *position * transformation, *color, - scale_factor, + scale_factor * transformation.scale_factor(), pixels, clip_mask, ); @@ -412,7 +412,7 @@ impl Backend { *horizontal_alignment, *vertical_alignment, *shaping, - scale_factor, + scale_factor * transformation.scale_factor(), pixels, clip_mask, ); @@ -624,10 +624,10 @@ fn into_color(color: Color) -> tiny_skia::Color { fn into_transform(transformation: Transformation) -> tiny_skia::Transform { tiny_skia::Transform { - sx: transformation.scale_x(), + sx: transformation.scale_factor(), kx: 0.0, ky: 0.0, - sy: transformation.scale_y(), + sy: transformation.scale_factor(), tx: transformation.translation_x(), ty: transformation.translation_y(), } diff --git a/wgpu/src/backend.rs b/wgpu/src/backend.rs index 65c63f192b..b4de5e8344 100644 --- a/wgpu/src/backend.rs +++ b/wgpu/src/backend.rs @@ -142,8 +142,8 @@ impl Backend { } if !layer.meshes.is_empty() { - let scaled = transformation - * Transformation::scale(scale_factor, scale_factor); + let scaled = + transformation * Transformation::scale(scale_factor); self.triangle_pipeline.prepare( device, @@ -156,8 +156,8 @@ impl Backend { #[cfg(any(feature = "image", feature = "svg"))] { if !layer.images.is_empty() { - let scaled = transformation - * Transformation::scale(scale_factor, scale_factor); + let scaled = + transformation * Transformation::scale(scale_factor); self.image_pipeline.prepare( device, diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs index 93f96b9bf1..00ebc14aeb 100644 --- a/wgpu/src/layer.rs +++ b/wgpu/src/layer.rs @@ -124,7 +124,7 @@ impl<'a> Layer<'a> { paragraph: paragraph.clone(), position: *position * transformation, color: *color, - scale: transformation.scale_y(), + scale: transformation.scale_factor(), }); } Primitive::Text { @@ -143,7 +143,7 @@ impl<'a> Layer<'a> { layer.text.push(Text::Cached(text::Cached { content, bounds: *bounds * transformation, - size: *size * transformation.scale_y(), + size: *size * transformation.scale_factor(), line_height: *line_height, color: *color, font: *font,