39 : base(new
ScriptNode[] { r, i, dr, R, p, Palette, DimX, DimY },
51 : base(new
ScriptNode[] { r, i, dr, R, p, Palette, DimX },
63 : base(new
ScriptNode[] { r, i, dr, R, p, Palette },
89 return new string[] {
"r",
"i",
"dr",
"R",
"p",
"Palette",
"DimX",
"DimY" };
98 string ColorExpression =
null;
103 double Rr, Ri, pr, pi;
111 if ((Obj =
Arguments[3].AssociatedObjectValue) is Complex)
113 Complex z = (Complex)Obj;
123 if ((Obj =
Arguments[4].AssociatedObjectValue) is Complex)
125 Complex z = (Complex)Obj;
140 ColorExpression = this.Arguments[i].SubExpression;
145 Palette = ColorModels.RandomLinearAnalogousHSL.CreatePalette(128, 4, out
int Seed,
this,
Variables);
146 ColorExpression =
"RandomLinearAnalogousHSL(128,4," + Seed.ToString() +
")";
148 if (i < c && this.Arguments[i] is
null)
164 throw new ScriptRuntimeException(
"Parameter mismatch in call to NovaFractal(r,c,dr,Coefficients[,Palette][,dimx[,dimy]]).",
168 if (dimx <= 0 || dimx > 5000 || dimy <= 0 || dimy > 5000)
171 return CalcNova(
Variables, rc, ic, dr, Rr, Ri, pr, pi, Palette, dimx, dimy,
this, this.FractalZoomScript,
172 new object[] { Palette, dimx, dimy, Rr, Ri, pr, pi, ColorExpression });
175 private string FractalZoomScript(
double r,
double i,
double Size,
object State)
177 object[] Parameters = (
object[])State;
178 int DimX = (int)Parameters[1];
179 int DimY = (int)Parameters[2];
180 double Rr = (double)Parameters[3];
181 double Ri = (double)Parameters[4];
182 double pr = (double)Parameters[5];
183 double pi = (double)Parameters[6];
184 string ColorExpression = (string)Parameters[7];
186 StringBuilder sb =
new StringBuilder();
188 sb.Append(
"NovaFractal(");
214 if (!
string.IsNullOrEmpty(ColorExpression))
217 sb.Append(ColorExpression);
221 sb.Append(DimX.ToString());
223 sb.Append(DimY.ToString());
226 return sb.ToString();
233 double pr,
double pi, SKColor[] Palette,
int Width,
int Height,
ScriptNode Node, FractalZoomScript FractalZoomScript,
object State)
238 double r0, i0, r1, i1;
241 double zr, zi, zr2, zi2, zr3, zi3, zr4, zi4;
255 greens =
new byte[N];
258 for (x = 0; x < N; x++)
262 greens[x] = cl.Green;
266 int size = Width * Height * 4;
269 byte[] rgb =
new byte[size];
272 r0 = rCenter - rDelta;
273 r1 = rCenter + rDelta;
275 aspect = ((double)Width) / Height;
277 i0 = iCenter - rDelta / aspect;
278 i1 = iCenter + rDelta / aspect;
280 dr = (r1 - r0) / Width;
281 di = (i1 - i0) / Height;
283 for (y = 0, i = i0, index = 0; y < Height; y++, i += di)
285 for (x = 0, r = r0; x < Width; x++, r += dr)
301 lnz = Math.Log(Math.Sqrt(zr * zr + zi * zi));
302 argz = Math.Atan2(zi, zr);
303 amp = Math.Exp(pr * lnz - pi * argz);
304 phi = pi * lnz + pr * argz;
306 zr2 = amp * Math.Cos(phi) - 1;
307 zi2 = amp * Math.Sin(phi);
314 amp = Math.Exp((pr - 1) * lnz - pi * argz);
315 phi = pi * lnz + (pr - 1) * argz;
317 zr3 = amp * Math.Cos(phi);
318 zi3 = amp * Math.Sin(phi);
320 Temp = pr * zr3 - pi * zi3;
321 zi3 = pr * zi3 + pi * zr3;
326 Temp = 1.0 / (zr3 * zr3 + zi3 * zi3);
327 zr4 = (zr2 * zr3 + zi2 * zi3) * Temp;
328 zi4 = (zi2 * zr3 - zr2 * zi3) * Temp;
330 Temp = Rr * zr4 - Ri * zi4;
331 zi4 = Ri * zr4 + Rr * zi4;
337 Temp = Math.Sqrt(zr4 * zr4 + zi4 * zi4);
339 while ((Temp > Conv) && (Temp < Div) && (n++ < N));
341 if (Temp < Conv && n < N)
343 rgb[index++] = blues[n];
344 rgb[index++] = greens[n];
345 rgb[index++] = reds[n];
359 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
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.
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.