42 : base(new
ScriptNode[] { z, c, dr, Palette, DimX, DimY },
53 : base(new
ScriptNode[] { z, c, dr, Palette, DimX },
85 return new string[] {
"z",
"c",
"dr",
"Palette",
"DimX",
"DimY" };
94 string ColorExpression =
null;
107 Obj =
Arguments[i++].AssociatedObjectValue;
108 if (Obj is Complex z)
122 Obj =
Arguments[i++].AssociatedObjectValue;
126 throw new ScriptRuntimeException(
"Lambda expression in calls to JuliaFractal() must be of one variable.",
this);
130 fDef = this.Arguments[i - 1];
132 else if (Obj is Complex z2)
153 ColorExpression = this.Arguments[i].SubExpression;
158 Palette = ColorModels.RandomLinearAnalogousHSL.CreatePalette(1024, 16, out
int Seed,
this,
Variables);
159 ColorExpression =
"RandomLinearAnalogousHSL(1024,16," + Seed.ToString() +
")";
161 if (i < c && this.Arguments[i] is
null)
177 throw new ScriptRuntimeException(
"Parameter mismatch in call to JuliaFractal(z,c|f,dr[,Palette][,dimx[,dimy]]).",
181 if (dimx <= 0 || dimx > 5000 || dimy <= 0 || dimy > 5000)
186 return CalcJulia(rc, ic, f, fDef, dr, Palette, dimx, dimy,
this,
Variables,
187 this.FractalZoomScript,
new object[] { Palette, dimx, dimy, r0, i0, ColorExpression, fDef });
191 return CalcJulia(
Variables, rc, ic, r0, i0, dr, Palette, dimx, dimy,
this,
192 this.FractalZoomScript,
new object[] { Palette, dimx, dimy, r0, i0, ColorExpression, fDef });
196 private string FractalZoomScript(
double r,
double i,
double Size,
object State)
198 object[] Parameters = (
object[])State;
199 int DimX = (int)Parameters[1];
200 int DimY = (int)Parameters[2];
201 double r0 = (double)Parameters[3];
202 double i0 = (double)Parameters[4];
203 string ColorExpression = (string)Parameters[5];
206 StringBuilder sb =
new StringBuilder();
208 sb.Append(
"JuliaFractal((");
228 if (!
string.IsNullOrEmpty(ColorExpression))
231 sb.Append(ColorExpression);
235 sb.Append(DimX.ToString());
237 sb.Append(DimY.ToString());
240 return sb.ToString();
247 SKColor[] Palette,
int Width,
int Height,
ScriptNode Node, FractalZoomScript FractalZoomScript,
object State)
252 double r0, i0, r1, i1;
255 double zr, zi, zrt, zr2, zi2;
264 greens =
new byte[N];
267 for (x = 0; x < N; x++)
271 greens[x] = cl.Green;
275 int size = Width * Height * 4;
276 byte[] rgb =
new byte[size];
279 r0 = rCenter - rDelta;
280 r1 = rCenter + rDelta;
282 aspect = ((double)Width) / Height;
284 i0 = iCenter - rDelta / aspect;
285 i1 = iCenter + rDelta / aspect;
287 dr = (r1 - r0) / Width;
288 di = (i1 - i0) / Height;
290 for (y = 0, i = i0, index = 0; y < Height; y++, i += di)
292 for (x = 0, r = r0; x < Width; x++, r += dr)
301 while (zr2 + zi2 < 9 && n < N)
304 zrt = zr2 - zi2 + R0;
305 zi = 2 * zr * zi + I0;
320 rgb[index++] = blues[n];
321 rgb[index++] = greens[n];
322 rgb[index++] = reds[n];
330 return new FractalGraph(
Variables, Pixels, r0, i0, r1, i1, rDelta * 2,
true, Node,
FractalZoomScript, State);
338 FractalZoomScript FractalZoomScript,
object State)
343 double r0, i0, r1, i1;
353 greens =
new byte[N];
356 for (x = 0; x < N; x++)
360 greens[x] = cl.Green;
364 int size = Width * Height * 4;
365 byte[] rgb =
new byte[size];
372 r0 = rCenter - rDelta;
373 r1 = rCenter + rDelta;
375 aspect = ((double)Width) / Height;
377 i0 = iCenter - rDelta / aspect;
378 i1 = iCenter + rDelta / aspect;
380 dr = (r1 - r0) / Width;
381 di = (i1 - i0) / Height;
383 for (y = 0, i = i0; y < Height; y++, i += di)
385 Complex[] Row =
new Complex[Width];
386 int[] Offset =
new int[Width];
389 for (x = 0, x2 = y * Width * 4, r = r0; x < Width; x++, r += dr, x2 += 4)
391 Row[x] =
new Complex(r, i);
399 while (n < N && c > 0)
404 Row = Obj.AssociatedObjectValue as Complex[];
409 "and return complex vectors of equal length. Type returned: " +
410 Obj.GetType().FullName, Node);
412 else if (Row.Length != c)
415 "and return complex vectors of equal length. Length returned: " +
416 Row.Length.ToString() +
". Expected: " + c.ToString(), Node);
419 for (x = x2 = 0; x < c; x++)
447 rgb[j++] = greens[n];
457 Array.Resize(ref Row, x2);
458 Array.Resize(ref Offset, x2);
465 for (x = 0; x < c; x++)
479 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 Julia set Fractal Image
static FractalGraph CalcJulia(double rCenter, double iCenter, ILambdaExpression f, ScriptNode _, double rDelta, SKColor[] Palette, int Width, int Height, ScriptNode Node, Variables Variables, FractalZoomScript FractalZoomScript, object State)
TODO
static FractalGraph CalcJulia(Variables Variables, double rCenter, double iCenter, double R0, double I0, double rDelta, SKColor[] Palette, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State)
TODO
JuliaFractal(ScriptNode z, ScriptNode c, ScriptNode dr, int Start, int Length, Expression Expression)
TODO
JuliaFractal(ScriptNode z, ScriptNode c, ScriptNode dr, ScriptNode Palette, int Start, int Length, Expression Expression)
TODO
override IElement Evaluate(IElement[] Arguments, Variables Variables)
TODO
JuliaFractal(ScriptNode z, ScriptNode c, ScriptNode dr, ScriptNode Palette, ScriptNode DimX, ScriptNode DimY, int Start, int Length, Expression Expression)
TODO
override string[] DefaultArgumentNames
TODO
JuliaFractal(ScriptNode z, ScriptNode c, ScriptNode dr, ScriptNode Palette, ScriptNode DimX, int Start, int Length, Expression Expression)
TODO
override string FunctionName
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.
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.
Basic interface for all types of elements.
Base interface for lambda expressions.
IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the lambda expression.
int NrArguments
Number of arguments.
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.