Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.3 MiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 588 B After Width: | Height: | Size: 588 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
Before Width: | Height: | Size: 148 KiB After Width: | Height: | Size: 148 KiB |
Before Width: | Height: | Size: 218 KiB After Width: | Height: | Size: 218 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 92 KiB |
Before Width: | Height: | Size: 254 KiB After Width: | Height: | Size: 254 KiB |
@ -1,66 +0,0 @@
|
|||||||
import 'dart:math' as math;
|
|
||||||
import 'package:flame/extensions.dart';
|
|
||||||
import 'package:flame/game.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
import 'package:pinball_components/src/components/components.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
group('ArcShape', () {
|
|
||||||
test('can be instantiated', () {
|
|
||||||
expect(
|
|
||||||
ArcShape(
|
|
||||||
center: Vector2.zero(),
|
|
||||||
arcRadius: 10,
|
|
||||||
angle: 2 * math.pi,
|
|
||||||
),
|
|
||||||
isNotNull,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
group('copyWith', () {
|
|
||||||
test(
|
|
||||||
'copies correctly '
|
|
||||||
'when no argument specified', () {
|
|
||||||
final arcShape = ArcShape(
|
|
||||||
center: Vector2.zero(),
|
|
||||||
arcRadius: 10,
|
|
||||||
angle: 2 * math.pi,
|
|
||||||
);
|
|
||||||
final arcShapeCopied = arcShape.copyWith();
|
|
||||||
|
|
||||||
for (var index = 0; index < arcShape.vertices.length; index++) {
|
|
||||||
expect(
|
|
||||||
arcShape.vertices[index],
|
|
||||||
equals(arcShapeCopied.vertices[index]),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
test(
|
|
||||||
'copies correctly '
|
|
||||||
'when all arguments specified', () {
|
|
||||||
final arcShapeExpected = ArcShape(
|
|
||||||
center: Vector2.all(10),
|
|
||||||
arcRadius: 15,
|
|
||||||
angle: 2 * math.pi,
|
|
||||||
);
|
|
||||||
final arcShapeCopied = ArcShape(
|
|
||||||
center: Vector2.zero(),
|
|
||||||
arcRadius: 10,
|
|
||||||
angle: math.pi,
|
|
||||||
).copyWith(
|
|
||||||
center: Vector2.all(10),
|
|
||||||
arcRadius: 15,
|
|
||||||
angle: 2 * math.pi,
|
|
||||||
);
|
|
||||||
|
|
||||||
for (var index = 0; index < arcShapeCopied.vertices.length; index++) {
|
|
||||||
expect(
|
|
||||||
arcShapeCopied.vertices[index],
|
|
||||||
equals(arcShapeExpected.vertices[index]),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
import 'dart:math' as math;
|
|
||||||
import 'package:flame/extensions.dart';
|
|
||||||
import 'package:flame/game.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
import 'package:pinball_components/src/components/components.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
group('BezierCurveShape', () {
|
|
||||||
final controlPoints = [
|
|
||||||
Vector2(0, 0),
|
|
||||||
Vector2(10, 0),
|
|
||||||
Vector2(0, 10),
|
|
||||||
Vector2(10, 10),
|
|
||||||
];
|
|
||||||
|
|
||||||
test('can be instantiated', () {
|
|
||||||
expect(
|
|
||||||
BezierCurveShape(
|
|
||||||
controlPoints: controlPoints,
|
|
||||||
),
|
|
||||||
isNotNull,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
group('rotate', () {
|
|
||||||
test('returns vertices rotated', () {
|
|
||||||
const rotationAngle = 2 * math.pi;
|
|
||||||
final controlPoints = [
|
|
||||||
Vector2(0, 0),
|
|
||||||
Vector2(10, 0),
|
|
||||||
Vector2(0, 10),
|
|
||||||
Vector2(10, 10),
|
|
||||||
];
|
|
||||||
|
|
||||||
final bezierCurveShape = BezierCurveShape(
|
|
||||||
controlPoints: controlPoints,
|
|
||||||
);
|
|
||||||
final bezierCurveShapeRotated = BezierCurveShape(
|
|
||||||
controlPoints: controlPoints,
|
|
||||||
)..rotate(rotationAngle);
|
|
||||||
|
|
||||||
for (var index = 0; index < bezierCurveShape.vertices.length; index++) {
|
|
||||||
expect(
|
|
||||||
bezierCurveShape.vertices[index]..rotate(rotationAngle),
|
|
||||||
equals(bezierCurveShapeRotated.vertices[index]),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
import 'dart:math' as math;
|
|
||||||
import 'package:flame/extensions.dart';
|
|
||||||
import 'package:flame/game.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
import 'package:pinball_components/src/components/components.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
group('EllipseShape', () {
|
|
||||||
test('can be instantiated', () {
|
|
||||||
expect(
|
|
||||||
EllipseShape(
|
|
||||||
center: Vector2.zero(),
|
|
||||||
majorRadius: 10,
|
|
||||||
minorRadius: 8,
|
|
||||||
),
|
|
||||||
isNotNull,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
group('rotate', () {
|
|
||||||
test('returns vertices rotated', () {
|
|
||||||
const rotationAngle = 2 * math.pi;
|
|
||||||
final ellipseShape = EllipseShape(
|
|
||||||
center: Vector2.zero(),
|
|
||||||
majorRadius: 10,
|
|
||||||
minorRadius: 8,
|
|
||||||
);
|
|
||||||
final ellipseShapeRotated = EllipseShape(
|
|
||||||
center: Vector2.zero(),
|
|
||||||
majorRadius: 10,
|
|
||||||
minorRadius: 8,
|
|
||||||
)..rotate(rotationAngle);
|
|
||||||
|
|
||||||
for (var index = 0; index < ellipseShape.vertices.length; index++) {
|
|
||||||
expect(
|
|
||||||
ellipseShape.vertices[index]..rotate(rotationAngle),
|
|
||||||
equals(ellipseShapeRotated.vertices[index]),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
group('copyWith', () {
|
|
||||||
test('returns same shape when no properties are passed', () {
|
|
||||||
final ellipseShape = EllipseShape(
|
|
||||||
center: Vector2.zero(),
|
|
||||||
majorRadius: 10,
|
|
||||||
minorRadius: 8,
|
|
||||||
);
|
|
||||||
final ellipseShapeCopied = ellipseShape.copyWith();
|
|
||||||
|
|
||||||
for (var index = 0; index < ellipseShape.vertices.length; index++) {
|
|
||||||
expect(
|
|
||||||
ellipseShape.vertices[index],
|
|
||||||
equals(ellipseShapeCopied.vertices[index]),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
test('returns object with updated properties when are passed', () {
|
|
||||||
final ellipseShapeExpected = EllipseShape(
|
|
||||||
center: Vector2.all(10),
|
|
||||||
majorRadius: 10,
|
|
||||||
minorRadius: 8,
|
|
||||||
);
|
|
||||||
final ellipseShapeCopied = EllipseShape(
|
|
||||||
center: Vector2.zero(),
|
|
||||||
majorRadius: 10,
|
|
||||||
minorRadius: 8,
|
|
||||||
).copyWith(center: Vector2.all(10));
|
|
||||||
|
|
||||||
for (var index = 0;
|
|
||||||
index < ellipseShapeCopied.vertices.length;
|
|
||||||
index++) {
|
|
||||||
expect(
|
|
||||||
ellipseShapeCopied.vertices[index],
|
|
||||||
equals(ellipseShapeExpected.vertices[index]),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
@ -0,0 +1,20 @@
|
|||||||
|
import 'dart:math' as math;
|
||||||
|
import 'package:flame/extensions.dart';
|
||||||
|
import 'package:flame/game.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pinball_flame/pinball_flame.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('ArcShape', () {
|
||||||
|
test('can be instantiated', () {
|
||||||
|
expect(
|
||||||
|
ArcShape(
|
||||||
|
center: Vector2.zero(),
|
||||||
|
arcRadius: 10,
|
||||||
|
angle: 2 * math.pi,
|
||||||
|
),
|
||||||
|
isA<ArcShape>(),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
import 'package:flame/extensions.dart';
|
||||||
|
import 'package:flame/game.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pinball_flame/pinball_flame.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('BezierCurveShape', () {
|
||||||
|
test('can be instantiated', () {
|
||||||
|
expect(
|
||||||
|
BezierCurveShape(
|
||||||
|
controlPoints: [
|
||||||
|
Vector2(0, 0),
|
||||||
|
Vector2(10, 0),
|
||||||
|
Vector2(0, 10),
|
||||||
|
Vector2(10, 10),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
isA<BezierCurveShape>(),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
import 'dart:math' as math;
|
||||||
|
import 'package:flame/extensions.dart';
|
||||||
|
import 'package:flame/game.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pinball_flame/pinball_flame.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('EllipseShape', () {
|
||||||
|
test('can be instantiated', () {
|
||||||
|
expect(
|
||||||
|
EllipseShape(
|
||||||
|
center: Vector2.zero(),
|
||||||
|
majorRadius: 10,
|
||||||
|
minorRadius: 8,
|
||||||
|
),
|
||||||
|
isA<EllipseShape>(),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('rotate returns vertices rotated', () {
|
||||||
|
const rotationAngle = 2 * math.pi;
|
||||||
|
final ellipseShape = EllipseShape(
|
||||||
|
center: Vector2.zero(),
|
||||||
|
majorRadius: 10,
|
||||||
|
minorRadius: 8,
|
||||||
|
);
|
||||||
|
final ellipseShapeRotated = EllipseShape(
|
||||||
|
center: Vector2.zero(),
|
||||||
|
majorRadius: 10,
|
||||||
|
minorRadius: 8,
|
||||||
|
)..rotate(rotationAngle);
|
||||||
|
|
||||||
|
for (var index = 0; index < ellipseShape.vertices.length; index++) {
|
||||||
|
expect(
|
||||||
|
ellipseShape.vertices[index]..rotate(rotationAngle),
|
||||||
|
equals(ellipseShapeRotated.vertices[index]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|