You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pinball/packages/pinball_components/lib/src/components/shapes/arc_shape.dart

52 lines
1.1 KiB

import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:geometry/geometry.dart';
/// {@template arc_shape}
/// Creates an arc.
/// {@endtemplate}
class ArcShape extends ChainShape {
/// {@macro arc_shape}
ArcShape({
required this.center,
required this.arcRadius,
required this.angle,
this.rotation = 0,
}) {
createChain(
calculateArc(
center: center,
radius: arcRadius,
angle: angle,
offsetAngle: rotation,
),
);
}
/// The center of the arc.
final Vector2 center;
/// The radius of the arc.
final double arcRadius;
/// Specifies the size of the arc, in radians.
///
/// For example, two pi returns a complete circumference.
final double angle;
/// Angle in radians to rotate the arc around its [center].
final double rotation;
ArcShape copyWith({
Vector2? center,
double? arcRadius,
double? angle,
double? rotation,
}) =>
ArcShape(
center: center ?? this.center,
arcRadius: arcRadius ?? this.arcRadius,
angle: angle ?? this.angle,
rotation: rotation ?? this.rotation,
);
}