Unverified Commit 43044114 authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Fix lerp to eccentric circle. (#108743)

parent 7f7854fb
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment