2using System.Collections.Generic;
3using System.Runtime.InteropServices;
37 return new string[] {
"c1",
"c2",
"p" };
60 object x1 =
Arguments[0].AssociatedObjectValue;
61 object x2 =
Arguments[1].AssociatedObjectValue;
71 else if (x1 is
Graph G1)
76 else if (x1 is SKImage I1)
92 else if (x2 is
Graph G2)
97 else if (x2 is SKImage I2)
108 if (Img1 is
null && Img2 is
null)
110 else if (Img1 is
null)
112 else if (Img2 is
null)
125 public static SKColor
BlendColors(SKColor c1, SKColor c2,
double p)
127 int R = (int)(c1.Red * (1 - p) + c2.Red * p + 0.5);
128 int G = (int)(c1.Green * (1 - p) + c2.Green * p + 0.5);
129 int B = (int)(c1.Blue * (1 - p) + c2.Blue * p + 0.5);
130 int A = (int)(c1.Alpha * (1 - p) + c2.Alpha * p + 0.5);
152 return new SKColor((
byte)R, (
byte)G, (
byte)B, (
byte)A);
165 byte[] Bin = (
byte[])Raw.
Binary.Clone();
166 int i, j, c = Raw.
Binary.Length;
168 byte G =
Color.Green;
170 byte A =
Color.Alpha;
172 for (i = 0; i < c; i++)
174 j = (int)(Bin[i] * (1 - p) + B * p + 0.5);
182 j = (int)(Bin[++i] * (1 - p) + G * p + 0.5);
190 j = (int)(Bin[++i] * (1 - p) + R * p + 0.5);
198 j = (int)(Bin[++i] * (1 - p) + A * p + 0.5);
220 throw new ArgumentException(
"Images not of the same size.", nameof(Image2));
224 byte[] Bin1 = (
byte[])Raw1.
Binary.Clone();
225 byte[] Bin2 = Raw2.
Binary;
226 int i, j, c = Bin1.Length;
228 if (Bin2.Length != c)
229 throw new ArgumentException(
"Images not of the same size.", nameof(Image2));
231 for (i = 0; i < c; i++)
233 j = (int)(Bin1[i] * (1 - p) + Bin2[i] * p + 0.5);
Class managing a script expression.
static double ToDouble(object Object)
Converts an object to a double value.
Blends colors c1 and c2 together using a blending factor 0<=p<=1. Any or both of c1 and c2 can be an ...
Blend(ScriptNode c1, ScriptNode c2, ScriptNode p, int Start, int Length, Expression Expression)
Blends colors c1 and c2 together using a blending factor 0<=p<=1. Any or both of c1 and c2 can be an ...
static SKColor BlendColors(SKColor c1, SKColor c2, double p)
Blends two colors using a blending factor.
override IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the function.
override string FunctionName
Name of the function
override string[] DefaultArgumentNames
Default Argument names
static PixelInformation BlendColors(PixelInformation Pixels, SKColor Color, double p)
Blends an image with a fixed color using a blending factor.
static PixelInformation BlendColors(PixelInformation Image1, PixelInformation Image2, double p)
Blends two images of the same size using a blending factor.
Returns a color value from a string.
Handles bitmap-based graphs.
static SKColor ToColor(object Object)
Converts an object to a color.
Base class for multivariate funcions.
ScriptNode[] Arguments
Function arguments.
static readonly ArgumentType[] argumentTypes3Scalar
Three scalar parameters.
Base class for all nodes in a parsed script tree.
int Length
Length of expression covered by node.
Expression Expression
Expression of which the node is a part.
int Start
Start position in script expression.
Basic interface for all types of elements.