Fix lerp to eccentric circle. (#108743)
This commit is contained in:
@@ -501,9 +501,9 @@ ShapeBorder? lerpBorder(StarBorder border, LerpTarget target, double t, {bool to
|
||||
switch (target) {
|
||||
case LerpTarget.circle:
|
||||
if (to) {
|
||||
return border.lerpTo(const CircleBorder(side: lerpToBorder), t);
|
||||
return border.lerpTo(const CircleBorder(side: lerpToBorder, eccentricity: 0.5), t);
|
||||
} else {
|
||||
return border.lerpFrom(const CircleBorder(side: lerpToBorder), t);
|
||||
return border.lerpFrom(const CircleBorder(side: lerpToBorder, eccentricity: 0.5), t);
|
||||
}
|
||||
case LerpTarget.roundedRect:
|
||||
if (to) {
|
||||
|
||||
@@ -232,6 +232,7 @@ class StarBorder extends OutlinedBorder {
|
||||
return StarBorder(
|
||||
side: BorderSide.lerp(a.side, side, t),
|
||||
points: lerpedPoints,
|
||||
squash: ui.lerpDouble(a.eccentricity, squash, t)!,
|
||||
rotation: rotation,
|
||||
innerRadiusRatio: ui.lerpDouble(math.cos(math.pi / lerpedPoints), innerRadiusRatio, t)!,
|
||||
pointRounding: ui.lerpDouble(1.0, pointRounding, t)!,
|
||||
@@ -244,6 +245,7 @@ class StarBorder extends OutlinedBorder {
|
||||
return StarBorder(
|
||||
side: BorderSide.lerp(a.side, side, t),
|
||||
points: lerpedPoints,
|
||||
squash: ui.lerpDouble(a.eccentricity, squash, t)!,
|
||||
rotation: rotation,
|
||||
innerRadiusRatio: ui.lerpDouble(1, innerRadiusRatio, t)!,
|
||||
pointRounding: ui.lerpDouble(0.5, pointRounding, t)!,
|
||||
@@ -312,6 +314,7 @@ class StarBorder extends OutlinedBorder {
|
||||
return StarBorder(
|
||||
side: BorderSide.lerp(side, b.side, t),
|
||||
points: lerpedPoints,
|
||||
squash: ui.lerpDouble(squash, b.eccentricity, t)!,
|
||||
rotation: rotation,
|
||||
innerRadiusRatio: ui.lerpDouble(innerRadiusRatio, math.cos(math.pi / lerpedPoints), t)!,
|
||||
pointRounding: ui.lerpDouble(pointRounding, 1.0, t)!,
|
||||
@@ -322,6 +325,7 @@ class StarBorder extends OutlinedBorder {
|
||||
return StarBorder(
|
||||
side: BorderSide.lerp(side, b.side, t),
|
||||
points: lerpedPoints,
|
||||
squash: ui.lerpDouble(squash, b.eccentricity, t)!,
|
||||
rotation: rotation,
|
||||
innerRadiusRatio: ui.lerpDouble(innerRadiusRatio, 1, t)!,
|
||||
pointRounding: ui.lerpDouble(pointRounding, 0.5, t)!,
|
||||
|
||||
@@ -152,12 +152,15 @@ void main() {
|
||||
testWidgets('StarBorder lerped with CircleBorder', (WidgetTester tester) async {
|
||||
const StarBorder from = StarBorder();
|
||||
const ShapeBorder otherBorder = CircleBorder();
|
||||
const ShapeBorder eccentricCircle = CircleBorder(eccentricity: 0.6);
|
||||
await testBorder(tester, 'to_circle_border_2', from, lerpTo: otherBorder, lerpAmount: 0.2);
|
||||
await testBorder(tester, 'to_circle_border_7', from, lerpTo: otherBorder, lerpAmount: 0.7);
|
||||
await testBorder(tester, 'to_circle_border_10', from, lerpTo: otherBorder, lerpAmount: 1.0);
|
||||
await testBorder(tester, 'from_circle_border_2', from, lerpFrom: otherBorder, lerpAmount: 0.2);
|
||||
await testBorder(tester, 'from_circle_border_7', from, lerpFrom: otherBorder, lerpAmount: 0.7);
|
||||
await testBorder(tester, 'from_circle_border_10', from, lerpFrom: otherBorder, lerpAmount: 1.0);
|
||||
await testBorder(tester, 'to_eccentric_circle_border', from, lerpTo: eccentricCircle, lerpAmount: 0.4);
|
||||
await testBorder(tester, 'from_eccentric_circle_border', from, lerpFrom: eccentricCircle, lerpAmount: 0.4);
|
||||
});
|
||||
|
||||
testWidgets('StarBorder lerped with RoundedRectangleBorder', (WidgetTester tester) async {
|
||||
|
||||
Reference in New Issue
Block a user