Skip to content

Commit

Permalink
Format, update rules, jonah review
Browse files Browse the repository at this point in the history
  • Loading branch information
dnfield committed Mar 2, 2022
1 parent e438d32 commit b872ed1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,16 @@ class AffineMatrix {
}

@override
int get hashCode => Object.hash(a, b, c, d, e, f);
int get hashCode => Object.hash(a, b, c, d, e, f, _m4_10);

@override
bool operator ==(Object other) {
return other is AffineMatrix &&
other.a == a &&
other.b == b &&
other.d == d &&
other.e == e;
other.e == e &&
other._m4_10 == _m4_10;
}

@override
Expand Down
5 changes: 3 additions & 2 deletions packages/vector_graphics_compiler/lib/src/geometry/path.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import 'dart:math' as math;

import 'package:meta/meta.dart';
import 'package:path_parsing/path_parsing.dart';

import 'basic_types.dart';
import 'matrix.dart';
import '../util.dart';

// This is a magic number used by impeller for radius approximation:
// https://github.com/flutter/impeller/blob/a2478aa4939a9a08c6c3810f72e0db42e7383a07/geometry/path_builder.cc#L9
// See https://spencermortensen.com/articles/bezier-circle/ for more information.
const double _kArcApproximationMagic = 0.551915024494;

/// Specifies the winding rule that decies how the interior of a [Path] is
Expand Down
7 changes: 4 additions & 3 deletions packages/vector_graphics_compiler/test/basic_types_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:vector_graphics_compiler/vector_graphics_compiler.dart';
import 'package:test/test.dart';

void main() {
test('Point tests', () {
test('Point tests', () {
expect(Point.zero.x, 0);
expect(Point.zero.y, 0);

Expand All @@ -18,8 +18,9 @@ void main() {
expect(Rect.zero.bottom, 0);

expect(
const Rect.fromLTRB(1, 2, 3, 4).expanded(const Rect.fromLTRB(0, 0, 10, 10)),
const Rect.fromLTRB(0, 0, 10 ,10),
const Rect.fromLTRB(1, 2, 3, 4)
.expanded(const Rect.fromLTRB(0, 0, 10, 10)),
const Rect.fromLTRB(0, 0, 10, 10),
);

expect(
Expand Down
8 changes: 8 additions & 0 deletions packages/vector_graphics_compiler/test/matrix_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,12 @@ void main() {
expect(rotatedRect.right + 20, lessThan(epsillon));
expect(rotatedRect.bottom - 30, lessThan(epsillon));
});

test('== and hashCode account for hidden field', () {
const AffineMatrix matrixA = AffineMatrix.identity;
const AffineMatrix matrixB = AffineMatrix(1, 0, 0, 1, 0, 0, 0);

expect(matrixA != matrixB, true);
expect(matrixA.hashCode != matrixB.hashCode, true);
});
}

0 comments on commit b872ed1

Please sign in to comment.