Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions packages/vector_graphics_compiler/test/matrix_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ void main() {
const matrix1 = AffineMatrix(2, 2, 3, 4, 5, 6);

final matrix4_1 = Matrix4.fromFloat64List(matrix1.toMatrix4());
expect(matrix1.scaled(2, 3).toMatrix4(), matrix4_1.scaled(2.0, 3.0).storage);
expect(matrix1.scaled(2, 3).toMatrix4(), matrix4_1.scaledByDouble(2, 3, 2, 1).storage);

expect(matrix1.scaled(2).toMatrix4(), matrix4_1.scaled(2.0, 2.0).storage);
expect(matrix1.scaled(2).toMatrix4(), matrix4_1.scaledByDouble(2, 2, 2, 1).storage);
});

test('Scale and multiply', () {
Expand All @@ -67,7 +67,7 @@ void main() {
final matrix4_2 = Matrix4.fromFloat64List(matrix2.toMatrix4());
expect(
matrix1.scaled(2, 3).multiplied(matrix2).toMatrix4(),
matrix4_1.scaled(2.0, 3.0).multiplied(matrix4_2).storage,
matrix4_1.scaledByDouble(2, 3, 2, 1).multiplied(matrix4_2).storage,
);
});

Expand All @@ -82,7 +82,7 @@ void main() {
const matrix1 = AffineMatrix(2, 2, 3, 4, 5, 6);

final matrix4_1 = Matrix4.fromFloat64List(matrix1.toMatrix4());
matrix4_1.translate(2.0, 3.0);
matrix4_1.translateByDouble(2, 3, 0, 1);
expect(matrix1.translated(2, 3).toMatrix4(), matrix4_1.storage);
});

Expand All @@ -94,7 +94,7 @@ void main() {
});

test('transformRect', () {
const epsillon = .0000001;
const epsilon = .0000001;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In Dart, double literals should not start with a leading decimal point. It is cleaner and more idiomatic to use a leading zero (e.g., '0.0000001') or scientific notation (e.g., '1e-7'), which also improves readability by avoiding the need to manually count leading zeros.

Suggested change
const epsilon = .0000001;
const epsilon = 1e-7;

const rectangle20x20 = Rect.fromLTRB(10, 20, 30, 40);

// Identity
Expand All @@ -110,10 +110,10 @@ void main() {
final Rect rotatedRect = AffineMatrix.identity
.rotated(math.pi / 2.0)
.transformRect(rectangle20x20);
expect(rotatedRect.left + 40, lessThan(epsillon));
expect(rotatedRect.top - 10, lessThan(epsillon));
expect(rotatedRect.right + 20, lessThan(epsillon));
expect(rotatedRect.bottom - 30, lessThan(epsillon));
expect(rotatedRect.left + 40, lessThan(epsilon));
expect(rotatedRect.top - 10, lessThan(epsilon));
expect(rotatedRect.right + 20, lessThan(epsilon));
expect(rotatedRect.bottom - 30, lessThan(epsilon));

// Translation
final Rect shiftedRect = AffineMatrix.identity.translated(10, 20).transformRect(rectangle20x20);
Expand Down
Loading