示例#1
0
        public static ShapeBorder lerp(ShapeBorder a, ShapeBorder b, float t)
        {
            ShapeBorder result = null;

            if (b != null)
            {
                result = b.lerpFrom(a, t);
            }

            if (result == null && a != null)
            {
                result = a.lerpTo(b, t);
            }

            return(result ?? (t < 0.5 ? a : b));
        }
示例#2
0
        public new static _CompoundBorder lerp(ShapeBorder a, ShapeBorder b, float t)
        {
            D.assert(a is _CompoundBorder || b is _CompoundBorder);
            List <ShapeBorder> aList = a is _CompoundBorder aBorder ? aBorder.borders : new List <ShapeBorder> {
                a
            };
            List <ShapeBorder> bList = b is _CompoundBorder bBorder ? bBorder.borders : new List <ShapeBorder> {
                b
            };
            List <ShapeBorder> results = new List <ShapeBorder>();
            int length = Mathf.Max(aList.Count, bList.Count);

            for (int index = 0; index < length; index += 1)
            {
                ShapeBorder localA = index < aList.Count ? aList[index] : null;
                ShapeBorder localB = index < bList.Count ? bList[index] : null;
                if (localA != null && localB != null)
                {
                    ShapeBorder localResult = localA.lerpTo(localB, t) ?? localB.lerpFrom(localA, t);
                    if (localResult != null)
                    {
                        results.Add(localResult);
                        continue;
                    }
                }

                if (localB != null)
                {
                    results.Add(localB.scale(t));
                }

                if (localA != null)
                {
                    results.Add(localA.scale(1.0f - t));
                }
            }

            return(new _CompoundBorder(results));
        }