4using System.Threading.Tasks;
40 : base(new
ScriptNode[] { r, i, dr, R, p, Palette, DimX, DimY },
52 : base(new
ScriptNode[] { r, i, dr, R, p, Palette, DimX },
64 : base(new
ScriptNode[] { r, i, dr, R, p, Palette },
90 return new string[] {
"r",
"i",
"dr",
"R",
"p",
"Palette",
"DimX",
"DimY" };
113 string ColorExpression =
null;
118 double Rr, Ri, pr, pi;
126 if ((Obj =
Arguments[3].AssociatedObjectValue) is Complex)
128 Complex z = (Complex)Obj;
138 if ((Obj =
Arguments[4].AssociatedObjectValue) is Complex)
140 Complex z = (Complex)Obj;
155 ColorExpression = this.Arguments[i].SubExpression;
160 Palette = ColorModels.RandomLinearAnalogousHSL.CreatePalette(128, 4, out
int Seed,
this,
Variables);
161 ColorExpression =
"RandomLinearAnalogousHSL(128,4," + Seed.ToString() +
")";
163 if (i < c && this.Arguments[i] is
null)
179 throw new ScriptRuntimeException(
"Parameter mismatch in call to NovaSmoothFractal(r,c,dr,Coefficients[,Palette][,dimx[,dimy]]).",
183 if (dimx <= 0 || dimx > 5000 || dimy <= 0 || dimy > 5000)
186 return await
CalcNova(rc, ic, dr, Rr, Ri, pr, pi, Palette, dimx, dimy,
this,
Variables, this.FractalZoomScript,
187 new object[] { Palette, dimx, dimy, Rr, Ri, pr, pi, ColorExpression });
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 double Rr = (double)Parameters[3];
196 double Ri = (double)Parameters[4];
197 double pr = (double)Parameters[5];
198 double pi = (double)Parameters[6];
199 string ColorExpression = (string)Parameters[7];
201 StringBuilder sb =
new StringBuilder();
203 sb.Append(
"NovaSmoothFractal(");
229 if (!
string.IsNullOrEmpty(ColorExpression))
232 sb.Append(ColorExpression);
236 sb.Append(DimX.ToString());
238 sb.Append(DimY.ToString());
241 return sb.ToString();
247 public static async Task<FractalGraph>
CalcNova(
double rCenter,
double iCenter,
double rDelta,
double Rr,
double Ri,
249 FractalZoomScript FractalZoomScript,
object State)
251 double r0, i0, r1, i1;
254 double zr, zi, zr2, zi2, zr3, zi3, zr4, zi4;
268 r0 = rCenter - rDelta;
269 r1 = rCenter + rDelta;
271 aspect = ((double)Width) / Height;
273 i0 = iCenter - rDelta / aspect;
274 i1 = iCenter + rDelta / aspect;
276 dr = (r1 - r0) / Width;
277 di = (i1 - i0) / Height;
279 int Size = Width * Height;
280 double[] ColorIndex =
new double[Size];
284 for (y = 0, i = i0, index = 0; y < Height; y++, i += di)
286 for (x = 0, r = r0; x < Width; x++, r += dr)
302 lnz = Math.Log(Math.Sqrt(zr * zr + zi * zi));
303 argz = Math.Atan2(zi, zr);
304 amp = Math.Exp(pr * lnz - pi * argz);
305 phi = pi * lnz + pr * argz;
307 zr2 = amp * Math.Cos(phi) - 1;
308 zi2 = amp * Math.Sin(phi);
315 amp = Math.Exp((pr - 1) * lnz - pi * argz);
316 phi = pi * lnz + (pr - 1) * argz;
318 zr3 = amp * Math.Cos(phi);
319 zi3 = amp * Math.Sin(phi);
321 Temp = pr * zr3 - pi * zi3;
322 zi3 = pr * zi3 + pi * zr3;
327 Temp = 1.0 / (zr3 * zr3 + zi3 * zi3);
328 zr4 = (zr2 * zr3 + zi2 * zi3) * Temp;
329 zi4 = (zi2 * zr3 - zr2 * zi3) * Temp;
331 Temp = Rr * zr4 - Ri * zi4;
332 zi4 = Ri * zr4 + Rr * zi4;
338 Temp = Math.Sqrt(zr4 * zr4 + zi4 * zi4);
340 while ((Temp > Conv) && (Temp < Div) && (n++ < N));
342 if (Temp < Conv && n < N)
343 ColorIndex[index++] = n;
345 ColorIndex[index++] = N;
Script runtime exception.
Class managing a script expression.
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 Nova Smooth Fractal Image
override IElement Evaluate(IElement[] Arguments, Variables Variables)
TODO
override string[] DefaultArgumentNames
TODO
NovaSmoothFractal(ScriptNode r, ScriptNode i, ScriptNode dr, ScriptNode R, ScriptNode p, ScriptNode Palette, int Start, int Length, Expression Expression)
TODO
static async Task< FractalGraph > CalcNova(double rCenter, double iCenter, double rDelta, double Rr, double Ri, double pr, double pi, SKColor[] Palette, int Width, int Height, ScriptNode Node, Variables Variables, FractalZoomScript FractalZoomScript, object State)
TODO
override async Task< IElement > EvaluateAsync(IElement[] Arguments, Variables Variables)
TODO
NovaSmoothFractal(ScriptNode r, ScriptNode i, ScriptNode dr, ScriptNode R, ScriptNode p, ScriptNode Palette, ScriptNode DimX, ScriptNode DimY, int Start, int Length, Expression Expression)
TODO
NovaSmoothFractal(ScriptNode r, ScriptNode i, ScriptNode dr, ScriptNode R, ScriptNode p, int Start, int Length, Expression Expression)
TODO
NovaSmoothFractal(ScriptNode r, ScriptNode i, ScriptNode dr, ScriptNode R, ScriptNode p, ScriptNode Palette, ScriptNode DimX, int Start, int Length, Expression Expression)
TODO
override string FunctionName
TODO
override bool IsAsynchronous
If the node (or its decendants) include asynchronous evaluation. Asynchronous nodes should be evaluat...
Exception thrown if an image with invalid size is requested.
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 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
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.
Expression Expression
Expression of which the node is a part.
int Start
Start position in script expression.
async Task Preview(Expression Expression, IElement Result)
Reports a preview of the final result.
Basic interface for all types of elements.
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.