diff --git a/core/src/avm1/globals/matrix.rs b/core/src/avm1/globals/matrix.rs index 0eca59541..e5adb3221 100644 --- a/core/src/avm1/globals/matrix.rs +++ b/core/src/avm1/globals/matrix.rs @@ -340,7 +340,7 @@ fn create_box<'gc>( 0.0 }; - let matrix = Matrix::create_box( + let matrix = Matrix::create_box_with_rotation( scale_x as f32, scale_y as f32, rotation as f32, diff --git a/core/src/context.rs b/core/src/context.rs index 94f91eb22..2a835860d 100644 --- a/core/src/context.rs +++ b/core/src/context.rs @@ -673,7 +673,7 @@ impl<'a, 'gc> RenderContext<'a, 'gc> { // Top self.commands.draw_rect( color, - Matrix::create_box(width, thickness_pixels, 0.0, bounds.x_min, bounds.y_min), + Matrix::create_box(width, thickness_pixels, bounds.x_min, bounds.y_min), ); // Bottom self.commands.draw_rect( @@ -681,7 +681,6 @@ impl<'a, 'gc> RenderContext<'a, 'gc> { Matrix::create_box( width, thickness_pixels, - 0.0, bounds.x_min, bounds.y_max - thickness, ), @@ -689,7 +688,7 @@ impl<'a, 'gc> RenderContext<'a, 'gc> { // Left self.commands.draw_rect( color, - Matrix::create_box(thickness_pixels, height, 0.0, bounds.x_min, bounds.y_min), + Matrix::create_box(thickness_pixels, height, bounds.x_min, bounds.y_min), ); // Right self.commands.draw_rect( @@ -697,7 +696,6 @@ impl<'a, 'gc> RenderContext<'a, 'gc> { Matrix::create_box( thickness_pixels, height, - 0.0, bounds.x_max - thickness, bounds.y_min, ), diff --git a/core/src/display_object.rs b/core/src/display_object.rs index b0f07080c..7db9b24d6 100644 --- a/core/src/display_object.rs +++ b/core/src/display_object.rs @@ -971,7 +971,6 @@ pub fn render_base<'gc>(this: DisplayObject<'gc>, context: &mut RenderContext<'_ Matrix::create_box( bounds.width().to_pixels() as f32, bounds.height().to_pixels() as f32, - 0.0, bounds.x_min, bounds.y_min, ), diff --git a/core/src/display_object/edit_text.rs b/core/src/display_object/edit_text.rs index 1f92eda5a..222aa817f 100644 --- a/core/src/display_object/edit_text.rs +++ b/core/src/display_object/edit_text.rs @@ -1046,7 +1046,6 @@ impl<'gc> EditText<'gc> { * Matrix::create_box( width.to_pixels() as f32, height.to_pixels() as f32, - 0.0, x, Twips::ZERO, ); @@ -1065,7 +1064,6 @@ impl<'gc> EditText<'gc> { * Matrix::create_box( cursor_width.to_pixels() as f32, height.to_pixels() as f32, - 0.0, x - cursor_width, Twips::ZERO, ); @@ -2173,7 +2171,6 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> { let mask = Matrix::create_box( edit_text.bounds.width().to_pixels() as f32, edit_text.bounds.height().to_pixels() as f32, - 0.0, Twips::ZERO, Twips::ZERO, ); diff --git a/core/src/display_object/stage.rs b/core/src/display_object/stage.rs index 19aa7cb2b..880e3c4b3 100644 --- a/core/src/display_object/stage.rs +++ b/core/src/display_object/stage.rs @@ -615,7 +615,6 @@ impl<'gc> Stage<'gc> { Matrix::create_box( viewport_width, margin_top, - 0.0, Twips::default(), Twips::default(), ), @@ -627,7 +626,6 @@ impl<'gc> Stage<'gc> { Matrix::create_box( viewport_width, margin_bottom, - 0.0, Twips::default(), Twips::from_pixels((viewport_height - margin_bottom) as f64), ), @@ -641,7 +639,6 @@ impl<'gc> Stage<'gc> { Matrix::create_box( margin_left, viewport_height, - 0.0, Twips::default(), Twips::default(), ), @@ -653,7 +650,6 @@ impl<'gc> Stage<'gc> { Matrix::create_box( margin_right, viewport_height, - 0.0, Twips::from_pixels((viewport_width - margin_right) as f64), Twips::default(), ), diff --git a/render/src/matrix.rs b/render/src/matrix.rs index a336218c4..9da2eecc9 100644 --- a/render/src/matrix.rs +++ b/render/src/matrix.rs @@ -94,31 +94,31 @@ impl Matrix { } } - pub fn create_box( + pub fn create_box(scale_x: f32, scale_y: f32, translate_x: Twips, translate_y: Twips) -> Self { + Self { + a: scale_x, + c: 0.0, + tx: translate_x, + b: 0.0, + d: scale_y, + ty: translate_y, + } + } + + pub fn create_box_with_rotation( scale_x: f32, scale_y: f32, rotation: f32, translate_x: Twips, translate_y: Twips, ) -> Self { - if rotation != 0.0 { - Self { - a: rotation.cos() * scale_x, - c: -rotation.sin() * scale_x, - tx: translate_x, - b: rotation.sin() * scale_y, - d: rotation.cos() * scale_y, - ty: translate_y, - } - } else { - Self { - a: scale_x, - c: 0.0, - tx: translate_x, - b: 0.0, - d: scale_y, - ty: translate_y, - } + Self { + a: rotation.cos() * scale_x, + c: -rotation.sin() * scale_x, + tx: translate_x, + b: rotation.sin() * scale_y, + d: rotation.cos() * scale_y, + ty: translate_y, } } @@ -129,7 +129,7 @@ impl Matrix { translate_x: Twips, translate_y: Twips, ) -> Self { - Self::create_box( + Self::create_box_with_rotation( width / 1638.4, height / 1638.4, rotation,