Exemplo n.º 1
0
        private void WriteOut()
        {
            // Cache transform now:
            Css.Units.TransformValue existing = Animation.ComputedStyle[InnerPropertyInfo] as Css.Units.TransformValue;

            if (existing == null)
            {
                // Build and cache it now:
                existing         = new Css.Units.TransformValue(Animation.ComputedStyle, ActiveFunctions);
                existing.Changed = false;

                // Cache it now:
                Animation.ComputedStyle[InnerPropertyInfo] = existing;

                // Full layout required (so it gets adopted by kids):
                Animation.ComputedStyle.RequestLayout();
            }
            else
            {
                // Update its origin:
                existing.Origin  = ActiveFunctions;
                existing.Changed = false;
            }

            RawTransformValue = existing;
        }
Exemplo n.º 2
0
        /// <summary>Figures out what kind of lerp is required with the given from/to values.</summary>
        public void ApplyValues(Css.Value from, Css.Value to)
        {
            // Get computed:
            if (from != null)
            {
                from = from.Computed;

                if (from.IsType(typeof(Css.Keywords.None)))
                {
                    from = null;
                }
            }

            if (to != null)
            {
                to = to.Computed;

                if (to.IsType(typeof(Css.Keywords.None)))
                {
                    to = null;
                }
            }

            // If both are null, do nothing.
            if (to == null && from == null)
            {
                return;
            }

            // If either is a cached transformValue, pull the origin:
            if (to != null && to is Css.Units.TransformValue)
            {
                Css.Units.TransformValue rawTo = to as Css.Units.TransformValue;
                to = rawTo.Origin;
            }

            if (from != null && from is Css.Units.TransformValue)
            {
                Css.Units.TransformValue rawFrom = from as Css.Units.TransformValue;
                from = rawFrom.Origin;
            }

            // If one or the other is null then it acts like the identity of the other.
            if (to != null && from != null)
            {
                // Check for functional equiv:
                if (!to.FunctionalEquals(from))
                {
                    // Matrix interpolation :'(

                    // Bake both matrices:
                    RenderableData rd = Animation.ComputedStyle.RenderData;

                    Matrix4x4 fromMatrix = Css.Properties.TransformProperty.Compute(from, rd);
                    Matrix4x4 toMatrix   = Css.Properties.TransformProperty.Compute(to, rd);

                    // If either is 3D then they both are treated as 3D values:
                    if (Css.Properties.TransformProperty.Is3D(from) || Css.Properties.TransformProperty.Is3D(to))
                    {
                        // 3D!

                        // Write out into this value (no prep required here):
                        FromFunctions = new InterpolationMatrix3D(fromMatrix);
                        ToFunctions   = new InterpolationMatrix3D(toMatrix);
                    }
                    else
                    {
                        // 2D!

                        // Write out into this value:
                        InterpolationMatrix fromInt = new InterpolationMatrix(fromMatrix);
                        InterpolationMatrix toInt   = new InterpolationMatrix(toMatrix);

                        // Prep for interpolation:
                        fromInt.PrepareForInterpolate(toInt);

                        ToFunctions   = toInt;
                        FromFunctions = fromInt;
                    }

                    // Copy the from value:
                    ActiveFunctions = FromFunctions.Copy();

                    // Write it back out:
                    WriteOut();
                    return;
                }
            }

            // Interpolate every parameter of each function (if the other is null, use 0)
            // Note! The same function can appear multiple times.
            ToFunctions   = to;
            FromFunctions = from;

            if (FromFunctions == null)
            {
                // Copy to (going from none) and set it all as zero:
                ActiveFunctions = ToFunctions.Copy();

                // Set it all to 'zero' (it's e.g. 1 for scale though!)
                SetDefaults(ActiveFunctions);
            }
            else
            {
                // Copy from:
                ActiveFunctions = FromFunctions.Copy();
            }

            // Write it back out:
            WriteOut();
        }