Skip to content

Commit

Permalink
refactor: Use Twips::ONE where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
kjarosh committed Dec 25, 2024
1 parent a55f5a3 commit 08c4bc7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
5 changes: 1 addition & 4 deletions render/src/bitmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,7 @@ impl PixelRegion {
let (min, max) = ((a.0.min(b.0), a.1.min(b.1)), (a.0.max(b.0), a.1.max(b.1)));

// Increase max by one pixel as we've calculated the *encompassed* max
let max = (
max.0 + Twips::from_pixels_i32(1),
max.1 + Twips::from_pixels_i32(1),
);
let max = (max.0 + Twips::ONE, max.1 + Twips::ONE);

// Make sure we're never going below 0
Self {
Expand Down
2 changes: 1 addition & 1 deletion render/src/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ mod tests {
Matrix {
a: 1.5,
c: 1.2,
tx: Twips::from_pixels(1.0),
tx: Twips::ONE,
b: -2.7,
d: 3.4,
ty: Twips::from_pixels(-2.4),
Expand Down
10 changes: 5 additions & 5 deletions swf/src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2816,10 +2816,10 @@ pub mod tests {
assert_eq!(
rectangle,
Rectangle {
x_min: Twips::from_pixels(-1.0),
y_min: Twips::from_pixels(-1.0),
x_max: Twips::from_pixels(1.0),
y_max: Twips::from_pixels(1.0),
x_min: -Twips::ONE,
y_min: -Twips::ONE,
x_max: Twips::ONE,
y_max: Twips::ONE,
}
);
}
Expand Down Expand Up @@ -2936,7 +2936,7 @@ pub mod tests {
);

let mut matrix = Matrix::IDENTITY;
matrix.tx = Twips::from_pixels(1.0);
matrix.tx = Twips::ONE;
let fill_style = FillStyle::Bitmap {
id: 33,
matrix,
Expand Down
2 changes: 1 addition & 1 deletion swf/src/test_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ pub fn tag_tests() -> Vec<TagTestData> {
align: TextAlign::Justify,
left_margin: Twips::from_pixels(3.0),
right_margin: Twips::from_pixels(4.0),
indent: Twips::from_pixels(1.0),
indent: Twips::ONE,
leading: Twips::from_pixels(2.0),
}))
.with_variable_name(
Expand Down
8 changes: 4 additions & 4 deletions swf/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2650,10 +2650,10 @@ mod tests {
#[test]
fn write_rectangle_signed() {
let rectangle = Rectangle {
x_min: Twips::from_pixels(-1.0),
x_max: Twips::from_pixels(1.0),
y_min: Twips::from_pixels(-1.0),
y_max: Twips::from_pixels(1.0),
x_min: -Twips::ONE,
x_max: Twips::ONE,
y_min: -Twips::ONE,
y_max: Twips::ONE,
};
let mut buf = Vec::new();
{
Expand Down

0 comments on commit 08c4bc7

Please sign in to comment.