1// Copyright 2014 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import 'package:flutter/animation.dart';
6import 'package:flutter/painting.dart';
7
8/// An interpolation between two fractional offsets.
9///
10/// This class specializes the interpolation of [Tween<FractionalOffset>] to be
11/// appropriate for fractional offsets.
12///
13/// See [Tween] for a discussion on how to use interpolation objects.
14///
15/// See also:
16///
17/// * [AlignmentTween], which interpolates between to [Alignment] objects.
18class FractionalOffsetTween extends Tween<FractionalOffset?> {
19 /// Creates a fractional offset tween.
20 ///
21 /// The [begin] and [end] properties may be null; the null value
22 /// is treated as meaning the center.
23 FractionalOffsetTween({ super.begin, super.end });
24
25 /// Returns the value this variable has at the given animation clock value.
26 @override
27 FractionalOffset? lerp(double t) => FractionalOffset.lerp(begin, end, t);
28}
29
30/// An interpolation between two alignments.
31///
32/// This class specializes the interpolation of [Tween<Alignment>] to be
33/// appropriate for alignments.
34///
35/// See [Tween] for a discussion on how to use interpolation objects.
36///
37/// See also:
38///
39/// * [AlignmentGeometryTween], which interpolates between two
40/// [AlignmentGeometry] objects.
41class AlignmentTween extends Tween<Alignment> {
42 /// Creates a fractional offset tween.
43 ///
44 /// The [begin] and [end] properties may be null; the null value
45 /// is treated as meaning the center.
46 AlignmentTween({ super.begin, super.end });
47
48 /// Returns the value this variable has at the given animation clock value.
49 @override
50 Alignment lerp(double t) => Alignment.lerp(begin, end, t)!;
51}
52
53/// An interpolation between two [AlignmentGeometry].
54///
55/// This class specializes the interpolation of [Tween<AlignmentGeometry>]
56/// to be appropriate for alignments.
57///
58/// See [Tween] for a discussion on how to use interpolation objects.
59///
60/// See also:
61///
62/// * [AlignmentTween], which interpolates between two [Alignment] objects.
63class AlignmentGeometryTween extends Tween<AlignmentGeometry?> {
64 /// Creates a fractional offset geometry tween.
65 ///
66 /// The [begin] and [end] properties may be null; the null value
67 /// is treated as meaning the center.
68 AlignmentGeometryTween({
69 super.begin,
70 super.end,
71 });
72
73 /// Returns the value this variable has at the given animation clock value.
74 @override
75 AlignmentGeometry? lerp(double t) => AlignmentGeometry.lerp(begin, end, t);
76}
77