38 : base(new
ScriptNode[] { r, i, dr, R, p, Palette, DimX, DimY },
50 : base(new
ScriptNode[] { r, i, dr, R, p, Palette, DimX },
62 : base(new
ScriptNode[] { r, i, dr, R, p, Palette },
88 return new string[] {
"r",
"i",
"dr",
"R",
"p",
"Palette",
"DimX",
"DimY" };
97 string ColorExpression =
null;
102 double Rr, Ri, pr, pi;
110 if ((Obj =
Arguments[3].AssociatedObjectValue) is Complex)
112 Complex z = (Complex)Obj;
122 if ((Obj =
Arguments[4].AssociatedObjectValue) is Complex)
124 Complex z = (Complex)Obj;
139 ColorExpression = this.Arguments[i].SubExpression;
144 Palette = ColorModels.RandomLinearAnalogousHSL.CreatePalette(128, 4, out
int Seed,
this,
Variables);
145 ColorExpression =
"RandomLinearAnalogousHSL(128,4," + Seed.ToString() +
")";
147 if (i < c && this.Arguments[i] is
null)
163 throw new ScriptRuntimeException(
"Parameter mismatch in call to NovaFractal(r,c,dr,Coefficients[,Palette][,dimx[,dimy]]).",
167 if (dimx <= 0 || dimx > 5000 || dimy <= 0 || dimy > 5000)
170 return CalcNova(
Variables, rc, ic, dr, Rr, Ri, pr, pi, Palette, dimx, dimy,
this, this.FractalZoomScript,
171 new object[] { Palette, dimx, dimy, Rr, Ri, pr, pi, ColorExpression });
174 private string FractalZoomScript(
double r,
double i,
double Size,
object State)
176 object[] Parameters = (
object[])State;
177 int DimX = (int)Parameters[1];
178 int DimY = (int)Parameters[2];
179 double Rr = (double)Parameters[3];
180 double Ri = (double)Parameters[4];
181 double pr = (double)Parameters[5];
182 double pi = (double)Parameters[6];
183 string ColorExpression = (string)Parameters[7];
185 StringBuilder sb =
new StringBuilder();
187 sb.Append(
"NovaFractal(");
213 if (!
string.IsNullOrEmpty(ColorExpression))
216 sb.Append(ColorExpression);
220 sb.Append(DimX.ToString());
222 sb.Append(DimY.ToString());
225 return sb.ToString();
232 double pr,
double pi, SKColor[] Palette,
int Width,
int Height,
ScriptNode Node, FractalZoomScript FractalZoomScript,
object State)
237 double r0, i0, r1, i1;
240 double zr, zi, zr2, zi2, zr3, zi3, zr4, zi4;
254 greens =
new byte[N];
257 for (x = 0; x < N; x++)
261 greens[x] = cl.Green;
265 int size = Width * Height * 4;
268 byte[] rgb =
new byte[size];
271 r0 = rCenter - rDelta;
272 r1 = rCenter + rDelta;
274 aspect = ((double)Width) / Height;
276 i0 = iCenter - rDelta / aspect;
277 i1 = iCenter + rDelta / aspect;
279 dr = (r1 - r0) / Width;
280 di = (i1 - i0) / Height;
282 for (y = 0, i = i0, index = 0; y < Height; y++, i += di)
284 for (x = 0, r = r0; x < Width; x++, r += dr)
300 lnz = Math.Log(Math.Sqrt(zr * zr + zi * zi));
301 argz = Math.Atan2(zi, zr);
302 amp = Math.Exp(pr * lnz - pi * argz);
303 phi = pi * lnz + pr * argz;
305 zr2 = amp * Math.Cos(phi) - 1;
306 zi2 = amp * Math.Sin(phi);
313 amp = Math.Exp((pr - 1) * lnz - pi * argz);
314 phi = pi * lnz + (pr - 1) * argz;
316 zr3 = amp * Math.Cos(phi);
317 zi3 = amp * Math.Sin(phi);
319 Temp = pr * zr3 - pi * zi3;
320 zi3 = pr * zi3 + pi * zr3;
325 Temp = 1.0 / (zr3 * zr3 + zi3 * zi3);
326 zr4 = (zr2 * zr3 + zi2 * zi3) * Temp;
327 zi4 = (zi2 * zr3 - zr2 * zi3) * Temp;
329 Temp = Rr * zr4 - Ri * zi4;
330 zi4 = Ri * zr4 + Rr * zi4;
336 Temp = Math.Sqrt(zr4 * zr4 + zi4 * zi4);
338 while ((Temp > Conv) && (Temp < Div) && (n++ < N));
340 if (Temp < Conv && n < N)
342 rgb[index++] = blues[n];
343 rgb[index++] = greens[n];
344 rgb[index++] = reds[n];
358 return new FractalGraph(
Variables, Pixels, r0, i0, r1, i1, rDelta * 2,
true, Node,
FractalZoomScript, State);
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 Fractal Image
NovaFractal(ScriptNode r, ScriptNode i, ScriptNode dr, ScriptNode R, ScriptNode p, int Start, int Length, Expression Expression)
TODO
static FractalGraph CalcNova(Variables Variables, double rCenter, double iCenter, double rDelta, double Rr, double Ri, double pr, double pi, SKColor[] Palette, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State)
TODO
NovaFractal(ScriptNode r, ScriptNode i, ScriptNode dr, ScriptNode R, ScriptNode p, ScriptNode Palette, ScriptNode DimX, int Start, int Length, Expression Expression)
TODO
NovaFractal(ScriptNode r, ScriptNode i, ScriptNode dr, ScriptNode R, ScriptNode p, ScriptNode Palette, int Start, int Length, Expression Expression)
TODO
override string FunctionName
TODO
NovaFractal(ScriptNode r, ScriptNode i, ScriptNode dr, ScriptNode R, ScriptNode p, ScriptNode Palette, ScriptNode DimX, ScriptNode DimY, int Start, int Length, Expression Expression)
TODO
override string[] DefaultArgumentNames
TODO
override IElement Evaluate(IElement[] Arguments, Variables Variables)
TODO
Defines a clickable fractal graph in the complex plane.
static SKColor[] ToPalette(ObjectVector Vector)
TODO
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.
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.