This repository was archived by the owner on Dec 27, 2024. It is now read-only.
File tree 2 files changed +26
-21
lines changed
desktop/CycleEditor/src/main/java/androidx/motionlayout/cycleEditor
2 files changed +26
-21
lines changed Original file line number Diff line number Diff line change @@ -696,20 +696,22 @@ public void normalize() {
696
696
}
697
697
698
698
double getP (double time ) {
699
+ if (time <= 0.0 ) {
700
+ return 0.0 ;
701
+ } else if (time >= 1 ) {
702
+ return 1.0 ;
703
+ }
699
704
int index = Arrays .binarySearch (mPosition , time );
700
- double p = 0 ;
701
- if (index > 0 ) {
702
- p = 1 ;
703
- } else if (index != 0 ) {
705
+ if (index < 0 ) {
704
706
index = -index - 1 ;
705
- double t = time ;
706
- double m =
707
- (mPeriod [index ] - mPeriod [index - 1 ]) / (mPosition [index ] - mPosition [index - 1 ]);
708
- p = mArea [index - 1 ]
709
- + (mPeriod [index - 1 ] - m * mPosition [index - 1 ]) * (t - mPosition [index - 1 ])
710
- + m * (t * t - mPosition [index - 1 ] * mPosition [index - 1 ]) / 2 ;
711
707
}
712
- return p ;
708
+
709
+ double t = time ;
710
+ double m =
711
+ (mPeriod [index ] - mPeriod [index - 1 ]) / (mPosition [index ] - mPosition [index - 1 ]);
712
+ return mArea [index - 1 ]
713
+ + (mPeriod [index - 1 ] - m * mPosition [index - 1 ]) * (t - mPosition [index - 1 ])
714
+ + m * (t * t - mPosition [index - 1 ] * mPosition [index - 1 ]) / 2 ;
713
715
}
714
716
715
717
public double getValue (double time ) {
Original file line number Diff line number Diff line change @@ -58,19 +58,22 @@ public Oscillator() {
58
58
}
59
59
60
60
double getP (double time ) {
61
+ if (time <= 0.0 ) {
62
+ return 0.0 ;
63
+ } else if (time >= 1 ) {
64
+ return 1.0 ;
65
+ }
61
66
int index = Arrays .binarySearch (mPosition , time );
62
- double p = 0 ;
63
- if (index > 0 ) {
64
- p = 1 ;
65
- } else if (index != 0 ) {
67
+ if (index < 0 ) {
66
68
index = -index - 1 ;
67
- double t = time ;
68
- double m = (mPeriod [index ] - mPeriod [index - 1 ]) / (mPosition [index ] - mPosition [index - 1 ]);
69
- p = mArea [index - 1 ]
70
- + (mPeriod [index - 1 ] - m * mPosition [index - 1 ]) * (t - mPosition [index - 1 ])
71
- + m * (t * t - mPosition [index - 1 ] * mPosition [index - 1 ]) / 2 ;
72
69
}
73
- return p ;
70
+
71
+ double t = time ;
72
+ double m =
73
+ (mPeriod [index ] - mPeriod [index - 1 ]) / (mPosition [index ] - mPosition [index - 1 ]);
74
+ return mArea [index - 1 ]
75
+ + (mPeriod [index - 1 ] - m * mPosition [index - 1 ]) * (t - mPosition [index - 1 ])
76
+ + m * (t * t - mPosition [index - 1 ] * mPosition [index - 1 ]) / 2 ;
74
77
}
75
78
76
79
public double getValue (double time ) {
You can’t perform that action at this time.
0 commit comments