28 : base(new
ScriptNode[] { z, dr, R, c, Palette, DimX, DimY },
40 : base(new
ScriptNode[] { z, dr, R, c, Palette, DimX },
52 : base(new
ScriptNode[] { z, dr, R, c, Palette },
66 ArgumentType.Normal },
89 return new string[] {
"z",
"dr",
"R",
"c",
"Palette",
"DimX",
"DimY" };
98 string ColorExpression =
null;
100 double[] Coefficients =
null;
101 Complex[] CoefficientsZ =
null;
110 Obj =
Arguments[i++].AssociatedObjectValue;
111 if (Obj is Complex z)
127 if (i < c && ((Obj =
Arguments[i].AssociatedObjectValue) is
double || Obj is Complex))
136 if (i < c && this.Arguments[i] is
null)
142 Coefficients = (
double[])
Arguments[i++].AssociatedObjectValue;
144 int j, d = Coefficients.
Length;
146 CoefficientsZ =
new Complex[d];
147 for (j = 0; j < d; j++)
148 CoefficientsZ[j] =
new Complex(Coefficients[j], 0);
151 CoefficientsZ = (Complex[])
Arguments[i++].AssociatedObjectValue;
161 CoefficientsZ =
new Complex[d];
162 for (j = 0; j < d; j++)
166 CoefficientsZ = Array.Empty<Complex>();
170 ColorExpression = this.Arguments[i].SubExpression;
175 Palette = ColorModels.RandomLinearAnalogousHSL.CreatePalette(128, 4, out
int Seed,
this,
Variables);
176 ColorExpression =
"RandomLinearAnalogousHSL(128,4," + Seed.ToString() +
")";
178 if (i < c && this.Arguments[i] is
null)
194 throw new ScriptRuntimeException(
"Parameter mismatch in call to NewtonBuilderFractal(r,c,dr,Coefficients[,Palette][,dimx[,dimy]]).",
198 if (dimx <= 0 || dimx > 5000 || dimy <= 0 || dimy > 5000)
201 return NewtonFractal.
CalcNewton(
Variables, rc, ic, dr, R, CoefficientsZ, Palette, dimx, dimy,
this, this.FractalZoomScript,
202 new object[] { Palette, dimx, dimy, R, CoefficientsZ, ColorExpression, rc, ic });
205 private string FractalZoomScript(
double r,
double i,
double Size,
object State)
207 object[] Parameters = (
object[])State;
208 int DimX = (int)Parameters[1];
209 int DimY = (int)Parameters[2];
210 Complex R = (Complex)Parameters[3];
211 Complex[] CoefficientsZ = (Complex[])Parameters[4];
212 string ColorExpression = (string)Parameters[5];
213 double rc = (double)Parameters[6];
214 double ic = (double)Parameters[7];
215 Complex z0 =
new Complex(r, i);
218 int c = CoefficientsZ.Length;
219 while (c > 1 && CoefficientsZ[c - 1].
Equals(0))
232 C2 =
new Complex[c + 1];
233 C2[0] = Complex.Zero;
234 for (j = 0; j < c; j++)
235 C2[j + 1] = CoefficientsZ[j];
237 for (j = 0; j < c; j++)
238 C2[j] -= z0 * CoefficientsZ[j];
241 StringBuilder sb =
new StringBuilder();
243 sb.Append(
"NewtonBuilderFractal((");
254 if (!
string.IsNullOrEmpty(ColorExpression))
257 sb.Append(ColorExpression);
261 sb.Append(DimX.ToString());
263 sb.Append(DimY.ToString());
266 return sb.ToString();
Script runtime exception.
Class managing a script expression.
static Complex ToComplex(object Object)
Converts an object to a complex value.
static double ToDouble(object Object)
Converts an object to a double value.
static string ToString(double Value)
Converts a value to a string, that can be parsed as part of an expression.
Calculates a Newton Fractal Image, but when clicked, adds a root to the underying polynomial,...
NewtonBuilderFractal(ScriptNode z, ScriptNode dr, ScriptNode R, int Start, int Length, Expression Expression)
TODO
NewtonBuilderFractal(ScriptNode z, ScriptNode dr, ScriptNode R, ScriptNode c, ScriptNode Palette, int Start, int Length, Expression Expression)
TODO
override IElement Evaluate(IElement[] Arguments, Variables Variables)
TODO
NewtonBuilderFractal(ScriptNode z, ScriptNode dr, ScriptNode R, ScriptNode c, ScriptNode Palette, ScriptNode DimX, int Start, int Length, Expression Expression)
TODO
override string FunctionName
TODO
NewtonBuilderFractal(ScriptNode z, ScriptNode dr, ScriptNode R, ScriptNode c, ScriptNode Palette, ScriptNode DimX, ScriptNode DimY, int Start, int Length, Expression Expression)
TODO
NewtonBuilderFractal(ScriptNode z, ScriptNode dr, ScriptNode R, ScriptNode c, int Start, int Length, Expression Expression)
TODO
override string[] DefaultArgumentNames
TODO
Calculates a Newton Fractal Image
static FractalGraph CalcNewton(Variables Variables, double rCenter, double iCenter, double rDelta, Complex R, double[] Coefficients, SKColor[] Palette, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State)
TODO
Exception thrown if an image with invalid size is requested.
Defines a clickable fractal graph in the complex plane.
static SKColor[] ToPalette(ObjectVector Vector)
TODO
Base class for multivariate funcions.
ScriptNode[] Arguments
Function arguments.
override bool Equals(object obj)
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.
object AssociatedObjectValue
Associated object value.
Basic interface for vectors.
int Dimension
Dimension of vector.
IElement GetElement(int Index)
Gets an element of the vector.
ArgumentType
Type of parameter used in a function definition or a lambda definition.