Esempio n. 1
0
        public override ShapeBorder lerpTo(ShapeBorder b, float t)
        {
            if (b is StadiumBorder stadiumBorder)
            {
                return(new _StadiumToCircleBorder(
                           side: BorderSide.lerp(this.side, stadiumBorder.side, t),
                           circleness: this.circleness * (1.0f - t)
                           ));
            }

            if (b is CircleBorder circleBorder)
            {
                return(new _StadiumToCircleBorder(
                           side: BorderSide.lerp(this.side, circleBorder.side, t),
                           circleness: this.circleness + (1.0f - this.circleness) * t
                           ));
            }

            if (b is _StadiumToCircleBorder border)
            {
                return(new _StadiumToCircleBorder(
                           side: BorderSide.lerp(this.side, border.side, t),
                           circleness: MathUtils.lerpFloat(this.circleness, border.circleness, t)
                           ));
            }

            return(base.lerpTo(b, t));
        }
Esempio n. 2
0
        public override ShapeBorder lerpFrom(ShapeBorder a, float t)
        {
            if (a is StadiumBorder stadiumBorder)
            {
                return(new _StadiumToCircleBorder(
                           side: BorderSide.lerp(stadiumBorder.side, this.side, t),
                           circleness: this.circleness * t
                           ));
            }

            if (a is CircleBorder circleBorder)
            {
                return(new _StadiumToCircleBorder(
                           side: BorderSide.lerp(circleBorder.side, this.side, t),
                           circleness: this.circleness + (1.0f - this.circleness) * (1.0f - t)
                           ));
            }

            if (a is _StadiumToCircleBorder border)
            {
                return(new _StadiumToCircleBorder(
                           side: BorderSide.lerp(border.side, this.side, t),
                           circleness: MathUtils.lerpFloat(border.circleness, this.circleness, t)
                           ));
            }

            return(base.lerpFrom(a, t));
        }
Esempio n. 3
0
        public override ShapeBorder lerpTo(ShapeBorder b, float t)
        {
            if (b is RoundedRectangleBorder rectBorder)
            {
                return(new _RoundedRectangleToCircleBorder(
                           side: BorderSide.lerp(side, rectBorder.side, t),
                           borderRadius: BorderRadius.lerp(borderRadius, rectBorder.borderRadius, t),
                           circleness: circleness * (1.0f - t)
                           ));
            }

            if (b is CircleBorder circleBorder)
            {
                return(new _RoundedRectangleToCircleBorder(
                           side: BorderSide.lerp(side, circleBorder.side, t),
                           borderRadius: borderRadius,
                           circleness: circleness + (1.0f - circleness) * t
                           ));
            }

            if (b is _RoundedRectangleToCircleBorder border)
            {
                return(new _RoundedRectangleToCircleBorder(
                           side: BorderSide.lerp(side, border.side, t),
                           borderRadius: BorderRadius.lerp(borderRadius, border.borderRadius, t),
                           circleness: MathUtils.lerpNullableFloat(circleness, border.circleness, t)
                           ));
            }

            return(base.lerpTo(b, t));
        }
Esempio n. 4
0
        public override ShapeBorder lerpTo(ShapeBorder b, float t)
        {
            if (b is StadiumBorder stadiumBorder)
            {
                return(new _StadiumToRoundedRectangleBorder(
                           side: BorderSide.lerp(this.side, stadiumBorder.side, t),
                           borderRadius: this.borderRadius,
                           rectness: this.rectness * (1.0f - t)
                           ));
            }

            if (b is RoundedRectangleBorder rectBorder)
            {
                return(new _StadiumToRoundedRectangleBorder(
                           side: BorderSide.lerp(this.side, rectBorder.side, t),
                           borderRadius: this.borderRadius,
                           rectness: this.rectness + (1.0f - this.rectness) * t
                           ));
            }

            if (b is _StadiumToRoundedRectangleBorder border)
            {
                return(new _StadiumToRoundedRectangleBorder(
                           side: BorderSide.lerp(this.side, border.side, t),
                           borderRadius: BorderRadius.lerp(this.borderRadius, border.borderRadius, t),
                           rectness: MathUtils.lerpFloat(this.rectness, border.rectness, t)
                           ));
            }

            return(base.lerpTo(b, t));
        }
Esempio n. 5
0
 public override ShapeBorder lerpFrom(ShapeBorder a, double t)
 {
     if (a is StadiumBorder stadiumBorder)
     {
         return(new _StadiumToRoundedRectangleBorder(
                    side: BorderSide.lerp(stadiumBorder.side, this.side, t),
                    borderRadius: this.borderRadius,
                    rectness: this.rectness * t
                    ));
     }
     if (a is RoundedRectangleBorder rectBorder)
     {
         return(new _StadiumToRoundedRectangleBorder(
                    side: BorderSide.lerp(rectBorder.side, this.side, t),
                    borderRadius: this.borderRadius,
                    rectness: this.rectness + (1.0 - this.rectness) * (1.0 - t)
                    ));
     }
     if (a is _StadiumToRoundedRectangleBorder border)
     {
         return(new _StadiumToRoundedRectangleBorder(
                    side: BorderSide.lerp(border.side, this.side, t),
                    borderRadius: BorderRadius.lerp(border.borderRadius, this.borderRadius, t),
                    rectness: MathUtils.lerpDouble(border.rectness, this.rectness, t)
                    ));
     }
     return(base.lerpFrom(a, t));
 }
Esempio n. 6
0
        public override ShapeBorder lerpTo(ShapeBorder b, float t)
        {
            if (b is StadiumBorder stadiumBorder)
            {
                return(new StadiumBorder(side: BorderSide.lerp(this.side, stadiumBorder.side, t)));
            }

            if (b is CircleBorder circleBorder)
            {
                return(new _StadiumToCircleBorder(
                           side: BorderSide.lerp(this.side, circleBorder.side, t),
                           circleness: t
                           ));
            }

            if (b is RoundedRectangleBorder rectBorder)
            {
                return(new _StadiumToRoundedRectangleBorder(
                           side: BorderSide.lerp(this.side, rectBorder.side, t),
                           borderRadius: rectBorder.borderRadius,
                           rectness: t
                           ));
            }

            return(base.lerpTo(b, t));
        }
Esempio n. 7
0
        public override ShapeBorder lerpFrom(ShapeBorder a, float t)
        {
            if (a is StadiumBorder stadiumBorder)
            {
                return(new _StadiumToRoundedRectangleBorder(
                           side: BorderSide.lerp(stadiumBorder.side, side, t),
                           borderRadius: borderRadius,
                           rectness: rectness * t
                           ));
            }

            if (a is RoundedRectangleBorder rectBorder)
            {
                return(new _StadiumToRoundedRectangleBorder(
                           side: BorderSide.lerp(rectBorder.side, side, t),
                           borderRadius: borderRadius,
                           rectness: rectness + (1.0f - rectness) * (1.0f - t)
                           ));
            }

            if (a is _StadiumToRoundedRectangleBorder border)
            {
                return(new _StadiumToRoundedRectangleBorder(
                           side: BorderSide.lerp(border.side, side, t),
                           borderRadius: BorderRadius.lerp(border.borderRadius, borderRadius, t),
                           rectness: MathUtils.lerpNullableFloat(border.rectness, rectness, t)
                           ));
            }

            return(base.lerpFrom(a, t));
        }
Esempio n. 8
0
        public override ShapeBorder lerpFrom(ShapeBorder a, float t)
        {
            if (a is RoundedRectangleBorder rectBorder)
            {
                return(new _RoundedRectangleToCircleBorder(
                           side: BorderSide.lerp(rectBorder.side, this.side, t),
                           borderRadius: BorderRadius.lerp(rectBorder.borderRadius, this.borderRadius, t),
                           circleness: this.circleness * t
                           ));
            }

            if (a is CircleBorder circleBorder)
            {
                return(new _RoundedRectangleToCircleBorder(
                           side: BorderSide.lerp(circleBorder.side, this.side, t),
                           borderRadius: this.borderRadius,
                           circleness: this.circleness + (1.0f - this.circleness) * (1.0f - t)
                           ));
            }

            if (a is _RoundedRectangleToCircleBorder border)
            {
                return(new _RoundedRectangleToCircleBorder(
                           side: BorderSide.lerp(border.side, this.side, t),
                           borderRadius: BorderRadius.lerp(border.borderRadius, this.borderRadius, t),
                           circleness: MathUtils.lerpFloat(border.circleness, this.circleness, t)
                           ));
            }

            return(base.lerpFrom(a, t));
        }
        public override ShapeBorder lerpTo(ShapeBorder b, double t)
        {
            if (b is RoundedRectangleBorder rectBorder)
            {
                return(new _RoundedRectangleToCircleBorder(
                           side: BorderSide.lerp(this.side, rectBorder.side, t),
                           borderRadius: BorderRadius.lerp(this.borderRadius, rectBorder.borderRadius, t),
                           circleness: this.circleness * (1.0 - t)
                           ));
            }

            if (b is CircleBorder circleBorder)
            {
                return(new _RoundedRectangleToCircleBorder(
                           side: BorderSide.lerp(this.side, circleBorder.side, t),
                           borderRadius: this.borderRadius,
                           circleness: this.circleness + (1.0 - this.circleness) * t
                           ));
            }

            if (b is _RoundedRectangleToCircleBorder border)
            {
                return(new _RoundedRectangleToCircleBorder(
                           side: BorderSide.lerp(this.side, border.side, t),
                           borderRadius: BorderRadius.lerp(this.borderRadius, border.borderRadius, t),
                           circleness: MathUtils.lerpDouble(this.circleness, border.circleness, t)
                           ));
            }

            return(base.lerpTo(b, t));
        }
Esempio n. 10
0
        public override ShapeBorder lerpFrom(ShapeBorder a, float t)
        {
            if (a is StadiumBorder stadiumBorder)
            {
                return(new StadiumBorder(side: BorderSide.lerp(stadiumBorder.side, this.side, t)));
            }

            if (a is CircleBorder circleBorder)
            {
                return(new _StadiumToCircleBorder(
                           side: BorderSide.lerp(circleBorder.side, this.side, t),
                           circleness: 1.0f - t
                           ));
            }

            if (a is RoundedRectangleBorder rectBorder)
            {
                return(new _StadiumToRoundedRectangleBorder(
                           side: BorderSide.lerp(rectBorder.side, this.side, t),
                           borderRadius: rectBorder.borderRadius,
                           rectness: 1.0f - t
                           ));
            }

            return(base.lerpFrom(a, t));
        }
Esempio n. 11
0
        public override ShapeBorder lerpTo(ShapeBorder b, float t)
        {
            if (b is CircleBorder border)
            {
                return(new CircleBorder(side: BorderSide.lerp(side, border.side, t)));
            }

            return(base.lerpTo(b, t));
        }
Esempio n. 12
0
        public override ShapeBorder lerpFrom(ShapeBorder a, float t)
        {
            if (a is CircleBorder border)
            {
                return(new CircleBorder(side: BorderSide.lerp(border.side, side, t)));
            }

            return(base.lerpFrom(a, t));
        }
Esempio n. 13
0
 public override ShapeBorder lerpTo(ShapeBorder b, double t)
 {
     if (b is BeveledRectangleBorder border)
     {
         return(new BeveledRectangleBorder(
                    side: BorderSide.lerp(this.side, border.side, t),
                    borderRadius: BorderRadius.lerp(this.borderRadius, border.borderRadius, t)
                    ));
     }
     return(base.lerpTo(b, t));
 }
Esempio n. 14
0
 public override ShapeBorder lerpFrom(ShapeBorder a, double t)
 {
     if (a is BeveledRectangleBorder border)
     {
         return(new BeveledRectangleBorder(
                    side: BorderSide.lerp(border.side, this.side, t),
                    borderRadius: BorderRadius.lerp(border.borderRadius, this.borderRadius, t)
                    ));
     }
     return(base.lerpFrom(a, t));
 }
 public override ShapeBorder lerpTo(ShapeBorder b, float t)
 {
     if (b is ContinuousRectangleBorder)
     {
         return(new ContinuousRectangleBorder(
                    side: BorderSide.lerp(this.side, (b as ContinuousRectangleBorder).side, t),
                    borderRadius: BorderRadius.lerp(this.borderRadius,
                                                    (b as ContinuousRectangleBorder).borderRadius, t)
                    ));
     }
     return(base.lerpTo(b, t));
 }
 public override ShapeBorder lerpFrom(ShapeBorder a, float t)
 {
     if (a is ContinuousRectangleBorder)
     {
         return(new ContinuousRectangleBorder(
                    side: BorderSide.lerp((a as ContinuousRectangleBorder).side, this.side, t),
                    borderRadius: BorderRadius.lerp((a as ContinuousRectangleBorder).borderRadius,
                                                    this.borderRadius, t)
                    ));
     }
     return(base.lerpFrom(a, t));
 }
Esempio n. 17
0
        public override ShapeBorder lerpFrom(ShapeBorder a, float t)
        {
            if (a is RoundedRectangleBorder border)
            {
                return(new RoundedRectangleBorder(
                           side: BorderSide.lerp(border.side, side, t),
                           borderRadius: BorderRadius.lerp(border.borderRadius, borderRadius, t)
                           ));
            }

            if (a is CircleBorder circleBorder)
            {
                return(new _RoundedRectangleToCircleBorder(
                           side: BorderSide.lerp(circleBorder.side, side, t),
                           borderRadius: borderRadius,
                           circleness: 1.0f - t
                           ));
            }

            return(base.lerpFrom(a, t));
        }
Esempio n. 18
0
        public override ShapeBorder lerpTo(ShapeBorder b, float t)
        {
            if (b is RoundedRectangleBorder border)
            {
                return(new RoundedRectangleBorder(
                           side: BorderSide.lerp(side, border.side, t),
                           borderRadius: BorderRadius.lerp(borderRadius, border.borderRadius, t)
                           ));
            }

            if (b is CircleBorder circleBorder)
            {
                return(new _RoundedRectangleToCircleBorder(
                           side: BorderSide.lerp(side, circleBorder.side, t),
                           borderRadius: borderRadius,
                           circleness: t
                           ));
            }

            return(base.lerpTo(b, t));
        }
Esempio n. 19
0
        public static Border lerp(Border a, Border b, double t)
        {
            if (a == null && b == null)
            {
                return(null);
            }

            if (a == null)
            {
                return((Border)b.scale(t));
            }

            if (b == null)
            {
                return((Border)a.scale(1.0 - t));
            }

            return(new Border(
                       top: BorderSide.lerp(a.top, b.top, t),
                       right: BorderSide.lerp(a.right, b.right, t),
                       bottom: BorderSide.lerp(a.bottom, b.bottom, t),
                       left: BorderSide.lerp(a.left, b.left, t)
                       ));
        }
Esempio n. 20
0
        public static BoxBorder lerp(BoxBorder a, BoxBorder b, float t)
        {
            D.assert(t != null);
            if ((a is Border || a == null) && (b is Border || b == null))
            {
                return(Border.lerp((Border)a, (Border)b, t));
            }
            if ((a is BorderDirectional || a == null) && (b is BorderDirectional || b == null))
            {
                return(BorderDirectional.lerp(a as BorderDirectional, b as BorderDirectional, t));
            }
            if (b is Border && a is BorderDirectional)
            {
                BoxBorder c = b;
                b = a;
                a = c;
                t = 1.0f - t;
            }

            if (a is Border border && b is BorderDirectional borderDirectional)
            {
                if (borderDirectional.start == BorderSide.none && borderDirectional.end == BorderSide.none)
                {
                    return(new Border(
                               top: BorderSide.lerp(border.top, borderDirectional.top, t),
                               right: BorderSide.lerp(border.right, BorderSide.none, t),
                               bottom: BorderSide.lerp(border.bottom, borderDirectional.bottom, t),
                               left: BorderSide.lerp(border.left, BorderSide.none, t)
                               ));
                }

                if (border.left == BorderSide.none && border.right == BorderSide.none)
                {
                    return(new BorderDirectional(
                               top: BorderSide.lerp(border.top, borderDirectional.top, t),
                               start: BorderSide.lerp(BorderSide.none, borderDirectional.start, t),
                               end: BorderSide.lerp(BorderSide.none, borderDirectional.end, t),
                               bottom: BorderSide.lerp(border.bottom, borderDirectional.bottom, t)
                               ));
                }

                if (t < 0.5f)
                {
                    return(new Border(
                               top: BorderSide.lerp(border.top, borderDirectional.top, t),
                               right: BorderSide.lerp(border.right, BorderSide.none, t * 2.0f),
                               bottom: BorderSide.lerp(border.bottom, borderDirectional.bottom, t),
                               left: BorderSide.lerp(border.left, BorderSide.none, t * 2.0f)
                               ));
                }

                return(new BorderDirectional(
                           top: BorderSide.lerp(border.top, borderDirectional.top, t),
                           start: BorderSide.lerp(BorderSide.none, borderDirectional.start, (t - 0.5f) * 2.0f),
                           end: BorderSide.lerp(BorderSide.none, borderDirectional.end, (t - 0.5f) * 2.0f),
                           bottom: BorderSide.lerp(border.bottom, borderDirectional.bottom, t)
                           ));
            }

            throw new UIWidgetsError(new List <DiagnosticsNode>()
            {
                new ErrorSummary("BoxBorder.lerp can only interpolate Border and BorderDirectional classes."),
                new ErrorDescription(
                    "BoxBorder.lerp() was called with two objects of type ${a.runtimeType} and ${b.runtimeType}:\n" +
                    "  $a\n" +
                    "  $b\n" +
                    "However, only Border and BorderDirectional classes are supported by this method."
                    ),
                new ErrorHint("For a more general interpolation method, consider using ShapeBorder.lerp instead.")
            });
        }