core: Use `swf::Matrix::translate` in more places

Replace direct instatiations of `swf::Matrix` where only `tx` and
`ty` are specified, and other fields are default.

This results in a slightly more shorter, readable code.
This commit is contained in:
relrelb 2022-05-29 21:03:22 +03:00 committed by relrelb
parent 60a1dbfb07
commit cec9850a33
2 changed files with 6 additions and 19 deletions

View File

@ -1621,11 +1621,7 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> {
let edit_text = self.0.read();
context.transform_stack.push(&Transform {
matrix: Matrix {
tx: edit_text.bounds.x_min,
ty: edit_text.bounds.y_min,
..Default::default()
},
matrix: Matrix::translate(edit_text.bounds.x_min, edit_text.bounds.y_min),
..Default::default()
});
@ -1659,12 +1655,10 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> {
// TODO: Where does this come from? How is this different than INTERNAL_PADDING? Does this apply to y as well?
// If this is actually right, offset the border in `redraw_border` instead of doing an extra push.
context.transform_stack.push(&Transform {
matrix: Matrix {
tx: Twips::from_pixels(Self::INTERNAL_PADDING)
- Twips::from_pixels(edit_text.hscroll),
ty: Twips::from_pixels(Self::INTERNAL_PADDING) - scroll_offset,
..Default::default()
},
matrix: Matrix::translate(
Twips::from_pixels(Self::INTERNAL_PADDING) - Twips::from_pixels(edit_text.hscroll),
Twips::from_pixels(Self::INTERNAL_PADDING) - scroll_offset,
),
..Default::default()
});

View File

@ -15,14 +15,7 @@ pub struct Transform {
impl From<Position<Twips>> for Transform {
fn from(pos: Position<Twips>) -> Self {
Self {
matrix: Matrix {
a: 1.0,
b: 0.0,
c: 0.0,
d: 1.0,
tx: pos.x(),
ty: pos.y(),
},
matrix: Matrix::translate(pos.x(), pos.y()),
color_transform: Default::default(),
}
}