Пример #1
0
        /// <summary>
        /// Evaluates the function.
        /// </summary>
        /// <param name="Arguments">Function arguments.</param>
        /// <param name="Variables">Variables collection.</param>
        /// <returns>Function result.</returns>
        public override IElement Evaluate(IElement[] Arguments, Variables Variables)
        {
            object  x1 = Arguments[0].AssociatedObjectValue;
            object  x2 = Arguments[1].AssociatedObjectValue;
            double  p = Expression.ToDouble(Arguments[2].AssociatedObjectValue);
            SKImage Img1, Img2;
            SKColor c1, c2;

            if (x1 is SKColor C1)
            {
                c1   = C1;
                Img1 = null;
            }
            else if (x1 is Graph G1)
            {
                Img1 = G1.CreateBitmap(Variables);
                c1   = SKColor.Empty;
            }
            else if (x1 is SKImage I1)
            {
                Img1 = I1;
                c1   = SKColor.Empty;
            }
            else
            {
                Img1 = null;
                c1   = Graph.ToColor(x1);
            }

            if (x2 is SKColor C2)
            {
                c2   = C2;
                Img2 = null;
            }
            else if (x2 is Graph G2)
            {
                Img2 = G2.CreateBitmap(Variables);
                c2   = SKColor.Empty;
            }
            else if (x2 is SKImage I2)
            {
                Img2 = I2;
                c2   = SKColor.Empty;
            }
            else
            {
                Img2 = null;
                c2   = Graph.ToColor(x2);
            }

            if (Img1 is null && Img2 is null)
            {
                return(new ObjectValue(BlendColors(c1, c2, p)));
            }