Example #1
0
        public static RadialGradient lerp(RadialGradient a, RadialGradient b, float t)
        {
            if (a == null && b == null)
            {
                return(null);
            }

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

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

            _ColorsAndStops interpolated = _ColorsAndStops._interpolateColorsAndStops(
                a.colors,
                a._impliedStops(),
                b.colors,
                b._impliedStops(),
                t);

            return(new RadialGradient(
                       center: Alignment.lerp(a.center, b.center, t),
                       radius: Mathf.Max(0.0f, MathUtils.lerpFloat(a.radius, b.radius, t)),
                       colors: interpolated.colors,
                       stops: interpolated.stops,
                       tileMode: t < 0.5 ? a.tileMode : b.tileMode
                       ));
        }
Example #2
0
        public static SweepGradient lerp(SweepGradient a, SweepGradient b, float t)
        {
            if (a == null && b == null)
            {
                return(null);
            }

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

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

            _ColorsAndStops interpolated =
                _ColorsAndStops._interpolateColorsAndStops(a.colors, a.stops, b.colors, b.stops, t);

            return(new SweepGradient(
                       center: Alignment.lerp(a.center, b.center, t),
                       startAngle: Mathf.Max(0.0f, MathUtils.lerpFloat(a.startAngle, b.startAngle, t)),
                       endAngle: Mathf.Max(0.0f, MathUtils.lerpFloat(a.endAngle, b.endAngle, t)),
                       colors: interpolated.colors,
                       stops: interpolated.stops,
                       tileMode: t < 0.5 ? a.tileMode : b.tileMode
                       ));
        }
Example #3
0
        public static LinearGradient lerp(LinearGradient a, LinearGradient b, float t)
        {
            if (a == null && b == null)
            {
                return(null);
            }

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

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

            _ColorsAndStops interpolated = _ColorsAndStops._interpolateColorsAndStops(
                a.colors,
                a._impliedStops(),
                b.colors,
                b._impliedStops(),
                t);

            return(new LinearGradient(
                       begin: Alignment.lerp(a.begin, b.begin, t),
                       end: Alignment.lerp(a.end, b.end, t),
                       colors: interpolated.colors,
                       stops: interpolated.stops,
                       tileMode: t < 0.5 ? a.tileMode : b.tileMode
                       ));
        }