Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
1ce3146d
Commit
1ce3146d
authored
Feb 25, 2016
by
Andrew Wilson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2160 from apwilson/curves
Add flipped curved
parents
4860e63f
20341577
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
10 deletions
+23
-10
curves.dart
packages/flutter/lib/src/animation/curves.dart
+23
-10
No files found.
packages/flutter/lib/src/animation/curves.dart
View file @
1ce3146d
...
...
@@ -16,20 +16,26 @@ const double _kCubicErrorBound = 0.001;
///
/// See [Curves] for a collection of common animation curves.
abstract
class
Curve
{
const
Curve
();
/// Returns the value of the curve at point [t].
///
/// The value of [t] must be between 0.0 and 1.0, inclusive.
double
transform
(
double
t
);
/// Returns a new curve that is the reversed inversion of this one.
/// This is often useful as the reverseCurve of an [Animation].
Curve
get
flipped
=>
new
FlippedCurve
(
this
);
}
/// The identity map over the unit interval.
class
Linear
implement
s
Curve
{
class
Linear
extend
s
Curve
{
const
Linear
();
double
transform
(
double
t
)
=>
t
;
}
/// A sawtooth curve that repeats a given number of times over the unit interval.
class
SawTooth
implement
s
Curve
{
class
SawTooth
extend
s
Curve
{
const
SawTooth
(
this
.
count
);
final
int
count
;
double
transform
(
double
t
)
{
...
...
@@ -39,7 +45,7 @@ class SawTooth implements Curve {
}
/// A curve that is 0.0 until start, then curved from 0.0 to 1.0 at end, then 1.0.
class
Interval
implement
s
Curve
{
class
Interval
extend
s
Curve
{
const
Interval
(
this
.
start
,
this
.
end
,
{
this
.
curve
:
Curves
.
linear
});
/// The smallest value for which this interval is 0.0.
...
...
@@ -65,7 +71,7 @@ class Interval implements Curve {
}
/// A cubic polynomial mapping of the unit interval.
class
Cubic
implement
s
Curve
{
class
Cubic
extend
s
Curve
{
const
Cubic
(
this
.
a
,
this
.
b
,
this
.
c
,
this
.
d
);
final
double
a
;
...
...
@@ -103,8 +109,15 @@ double _bounce(double t) {
return
7.5625
*
t
*
t
+
0.984375
;
}
/// A curve that is the reversed inversion of its given curve.
class
FlippedCurve
extends
Curve
{
FlippedCurve
(
this
.
curve
);
final
Curve
curve
;
double
transform
(
double
t
)
=>
1.0
-
curve
.
transform
(
1.0
-
t
);
}
/// An oscillating curve that grows in magnitude.
class
BounceInCurve
implement
s
Curve
{
class
BounceInCurve
extend
s
Curve
{
const
BounceInCurve
();
double
transform
(
double
t
)
{
return
1.0
-
_bounce
(
1.0
-
t
);
...
...
@@ -112,7 +125,7 @@ class BounceInCurve implements Curve {
}
/// An oscillating curve that shrink in magnitude.
class
BounceOutCurve
implement
s
Curve
{
class
BounceOutCurve
extend
s
Curve
{
const
BounceOutCurve
();
double
transform
(
double
t
)
{
return
_bounce
(
t
);
...
...
@@ -120,7 +133,7 @@ class BounceOutCurve implements Curve {
}
/// An oscillating curve that first grows and then shrink in magnitude.
class
BounceInOutCurve
implement
s
Curve
{
class
BounceInOutCurve
extend
s
Curve
{
const
BounceInOutCurve
();
double
transform
(
double
t
)
{
if
(
t
<
0.5
)
...
...
@@ -131,7 +144,7 @@ class BounceInOutCurve implements Curve {
}
/// An oscillating curve that grows in magnitude while overshooting its bounds.
class
ElasticInCurve
implement
s
Curve
{
class
ElasticInCurve
extend
s
Curve
{
const
ElasticInCurve
([
this
.
period
=
0.4
]);
final
double
period
;
double
transform
(
double
t
)
{
...
...
@@ -142,7 +155,7 @@ class ElasticInCurve implements Curve {
}
/// An oscillating curve that shrinks in magnitude while overshooting its bounds.
class
ElasticOutCurve
implement
s
Curve
{
class
ElasticOutCurve
extend
s
Curve
{
const
ElasticOutCurve
([
this
.
period
=
0.4
]);
final
double
period
;
double
transform
(
double
t
)
{
...
...
@@ -152,7 +165,7 @@ class ElasticOutCurve implements Curve {
}
/// An oscillating curve that grows and then shrinks in magnitude while overshooting its bounds.
class
ElasticInOutCurve
implement
s
Curve
{
class
ElasticInOutCurve
extend
s
Curve
{
const
ElasticInOutCurve
([
this
.
period
=
0.4
]);
final
double
period
;
double
transform
(
double
t
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment