Пример #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: AlignmentGeometry.lerp(a.center, b.center, t),
                       radius: Mathf.Max(0.0f, MathUtils.lerpNullableFloat(a.radius, b.radius, t)),
                       colors: interpolated.colors,
                       stops: interpolated.stops,
                       tileMode: t < 0.5 ? a.tileMode : b.tileMode,
                       focal: AlignmentGeometry.lerp(a.focal, b.focal, t),
                       focalRadius: Mathf.Max(0.0f, MathUtils.lerpNullableFloat(a.focalRadius, b.focalRadius, t))
                       ));
        }
Пример #2
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: AlignmentGeometry.lerp(a.begin, b.begin, t),
                       end: AlignmentGeometry.lerp(a.end, b.end, t),
                       colors: interpolated.colors,
                       stops: interpolated.stops,
                       tileMode: t < 0.5 ? a.tileMode : b.tileMode
                       ));
        }