Exemplo n.º 1
0
        public static ShapeDecoration lerp(ShapeDecoration a, ShapeDecoration b, float t)
        {
            if (a == null && b == null)
            {
                return(null);
            }

            if (a != null && b != null)
            {
                if (t == 0.0)
                {
                    return(a);
                }

                if (t == 1.0)
                {
                    return(b);
                }
            }

            return(new ShapeDecoration(
                       color: Color.lerp(a?.color, b?.color, t),
                       gradient: Gradient.lerp(a?.gradient, b?.gradient, t),
                       image: t < 0.5 ? a.image : b.image,
                       shadows: BoxShadow.lerpList(a?.shadows, b?.shadows, t),
                       shape: ShapeBorder.lerp(a?.shape, b?.shape, t)
                       ));
        }
 public BoxDecoration scale(float factor)
 {
     return(new BoxDecoration(
                color: Color.lerp(null, this.color, factor),
                image: this.image,
                border: Border.lerp(null, this.border, factor),
                borderRadius: BorderRadius.lerp(null, this.borderRadius, factor),
                boxShadow: BoxShadow.lerpList(null, this.boxShadow, factor),
                gradient: this.gradient?.scale(factor),
                backgroundBlendMode: this.backgroundBlendMode,
                shape: this.shape
                ));
 }
        public static BoxDecoration lerp(BoxDecoration a, BoxDecoration b, float t)
        {
            if (a == null && b == null)
            {
                return(null);
            }

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

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

            if (t == 0.0)
            {
                return(a);
            }

            if (t == 1.0)
            {
                return(b);
            }

            return(new BoxDecoration(
                       color: Color.lerp(a.color, b.color, t),
                       image: t < 0.5 ? a.image : b.image,
                       border: Border.lerp(a.border, b.border, t),
                       borderRadius: BorderRadius.lerp(a.borderRadius, b.borderRadius, t),
                       boxShadow: BoxShadow.lerpList(a.boxShadow, b.boxShadow, t),
                       gradient: Gradient.lerp(a.gradient, b.gradient, t),
                       backgroundBlendMode: t < 0.5 ? a.backgroundBlendMode : b.backgroundBlendMode,
                       shape: t < 0.5 ? a.shape : b.shape
                       ));
        }