4using System.Threading.Tasks;
34 : base(new
ScriptNode[] { z, f, dr, Palette, DimX, DimY },
45 : base(new
ScriptNode[] { z, f, dr, Palette, DimX },
77 return new string[] {
"z",
"f",
"dr",
"Palette",
"DimX",
"DimY" };
100 string ColorExpression =
null;
111 Obj =
Arguments[i++].AssociatedObjectValue;
112 if (Obj is Complex z)
124 throw new ScriptRuntimeException(
"Insufficient parameters in call to MandelbrotTopographyFractal().",
this);
126 Obj =
Arguments[i].AssociatedObjectValue;
129 fDef = this.Arguments[i++];
131 if (f.NrArguments != 2)
132 throw new ScriptRuntimeException(
"Lambda expression in calls to MandelbrotTopographyFractal() must be of two variables (z,c).",
this);
147 ColorExpression = this.Arguments[i].SubExpression;
152 Palette = ColorModels.RandomLinearAnalogousHSL.CreatePalette(1024, 16, out
int Seed,
this,
Variables);
153 ColorExpression =
"RandomLinearAnalogousHSL(1024,16," + Seed.ToString() +
")";
155 if (i < c && this.Arguments[i] is
null)
171 throw new ScriptRuntimeException(
"Parameter mismatch in call to MandelbrotSmoothGradientFractal(r,c,dr[,Palette][,dimx[,dimy]]).",
175 if (dimx <= 0 || dimx > 5000 || dimy <= 0 || dimy > 5000)
180 return await
CalcMandelbrot(rc, ic, dr, f,
Variables, Palette, dimx, dimy,
this, this.FractalZoomScript,
181 new object[] { Palette, dimx, dimy, ColorExpression, fDef });
186 new object[] { Palette, dimx, dimy, ColorExpression, fDef });
190 private string FractalZoomScript(
double r,
double i,
double Size,
object State)
192 object[] Parameters = (
object[])State;
193 int DimX = (int)Parameters[1];
194 int DimY = (int)Parameters[2];
195 string ColorExpression = (string)Parameters[3];
198 StringBuilder sb =
new StringBuilder();
200 sb.Append(
"MandelbrotSmoothGradientFractal((");
212 if (!
string.IsNullOrEmpty(ColorExpression))
215 sb.Append(ColorExpression);
219 sb.Append(DimX.ToString());
221 sb.Append(DimY.ToString());
224 return sb.ToString();
230 public static async Task<FractalGraph>
CalcMandelbrot(
double rCenter,
double iCenter,
double rDelta,
232 FractalZoomScript FractalZoomScript,
object State)
234 double r0, i0, r1, i1;
237 double zr, zi, zrt, zr2, zi2;
244 int Size = Width * Height;
245 double[] ColorIndex =
new double[Size];
249 r0 = rCenter - rDelta;
250 r1 = rCenter + rDelta;
252 aspect = ((double)Width) / Height;
254 i0 = iCenter - rDelta / aspect;
255 i1 = iCenter + rDelta / aspect;
257 dr = (r1 - r0) / Width;
258 di = (i1 - i0) / Height;
260 for (y = 0, i = i0; y < Height; y++, i += di)
262 for (x = 0, r = r0; x < Width; x++, r += dr)
271 while (zr2 + zi2 < 9 && n < N)
275 zi = 2 * zr * zi + i;
283 ColorIndex[Index++] = N;
285 ColorIndex[Index++] = n;
293 FractalGraph.
Diff(ColorIndex, Width, Height, out
double[] dx, out
double[] dy);
303 public static async Task<FractalGraph>
CalcMandelbrot(
double rCenter,
double iCenter,
double rDelta,
305 ScriptNode Node, FractalZoomScript FractalZoomScript,
object State)
307 double r0, i0, r1, i1;
316 int Size = Width * Height;
317 double[] ColorIndex =
new double[Size];
325 r0 = rCenter - rDelta;
326 r1 = rCenter + rDelta;
328 aspect = ((double)Width) / Height;
330 i0 = iCenter - rDelta / aspect;
331 i1 = iCenter + rDelta / aspect;
333 dr = (r1 - r0) / Width;
334 di = (i1 - i0) / Height;
336 for (y = 0, i = i0; y < Height; y++, i += di)
338 Complex[] Row =
new Complex[Width];
339 Complex[] Row0 =
new Complex[Width];
340 int[] Offset =
new int[Width];
343 for (x = 0, x2 = y * Width, r = r0; x < Width; x++, r += dr, x2++)
345 Row[x] = Row0[x] =
new Complex(r, i);
353 while (n < N && c > 0)
359 Row = Obj.AssociatedObjectValue as Complex[];
363 else if (Row.Length != c)
366 for (x = x2 = 0; x < c; x++)
395 Array.Resize(ref Row, x2);
396 Array.Resize(ref Row0, x2);
397 Array.Resize(ref Offset, x2);
404 for (x = 0; x < c; x++)
417 FractalGraph.
Diff(ColorIndex, Width, Height, out
double[] dx, out
double[] dy);
Script runtime exception.
Class managing a script expression.
static IElement Encapsulate(object Value)
Encapsulates an object.
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 Mandelbrot Smooth Fractal Image, where coloring is done in accordance with the ange of t...
MandelbrotSmoothGradientFractal(ScriptNode z, ScriptNode f, ScriptNode dr, ScriptNode Palette, int Start, int Length, Expression Expression)
TODO
MandelbrotSmoothGradientFractal(ScriptNode z, ScriptNode f, ScriptNode dr, ScriptNode Palette, ScriptNode DimX, int Start, int Length, Expression Expression)
TODO
MandelbrotSmoothGradientFractal(ScriptNode z, ScriptNode f, ScriptNode dr, int Start, int Length, Expression Expression)
TODO
override bool IsAsynchronous
If the node (or its decendants) include asynchronous evaluation. Asynchronous nodes should be evaluat...
static async Task< FractalGraph > CalcMandelbrot(double rCenter, double iCenter, double rDelta, ILambdaExpression f, Variables Variables, SKColor[] Palette, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State)
TODO
override async Task< IElement > EvaluateAsync(IElement[] Arguments, Variables Variables)
TODO
static async Task< FractalGraph > CalcMandelbrot(double rCenter, double iCenter, double rDelta, SKColor[] Palette, int Width, int Height, ScriptNode Node, Variables Variables, FractalZoomScript FractalZoomScript, object State)
TODO
override IElement Evaluate(IElement[] Arguments, Variables Variables)
TODO
override string[] DefaultArgumentNames
TODO
MandelbrotSmoothGradientFractal(ScriptNode z, ScriptNode f, ScriptNode dr, ScriptNode Palette, ScriptNode DimX, ScriptNode DimY, int Start, int Length, Expression Expression)
TODO
override string FunctionName
TODO
Exception thrown if an image with invalid size is requested.
Exception thrown if a lambda expression with invalid type is encountered.
Exception thrown if a lambda expression with invalid type is encountered.
Defines a clickable fractal graph in the complex plane.
static async Task Smooth(double[] ColorIndex, double[] Boundary, int Width, int Height, int N, SKColor[] Palette, ScriptNode Node, Variables Variables)
TODO
static void Diff(double[] ColorIndex, int Width, int Height, out double[] dx, out double[] dy)
TODO
static PixelInformation ToPixels(double[] ColorIndex, int Width, int Height, SKColor[] Palette)
TODO
static SKColor[] ToPalette(ObjectVector Vector)
TODO
static double[] FindBoundaries(double[] ColorIndex, int Width, int Height)
TODO
static void Angle(double[] ColorIndex, int Width, int Height, int N, double[] dx, double[] dy)
TODO
Handles bitmap-based graphs.
Base class for multivariate funcions.
ScriptNode[] Arguments
Function arguments.
Base class for all nodes in a parsed script tree.
int Length
Length of expression covered by node.
string SubExpression
Sub-expression defining the node.
Expression Expression
Expression of which the node is a part.
int Start
Start position in script expression.
void CopyTo(Variables Variables)
Copies available variables to another variable collection.
async Task Preview(Expression Expression, IElement Result)
Reports a preview of the final result.
Basic interface for all types of elements.
Base interface for lambda expressions.
IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the lambda expression.
delegate string FractalZoomScript(double r, double i, double Size, object State)
Generates new script when zoomed.
ArgumentType
Type of parameter used in a function definition or a lambda definition.