41 : base(new
ScriptNode[] { z, c, dr, Palette, DimX, DimY },
52 : base(new
ScriptNode[] { z, c, dr, Palette, DimX },
84 return new string[] {
"z",
"c",
"dr",
"Palette",
"DimX",
"DimY" };
93 string ColorExpression =
null;
107 Obj =
Arguments[i++].AssociatedObjectValue;
108 if (Obj is Complex z)
123 Obj =
Arguments[i++].AssociatedObjectValue;
127 throw new ScriptRuntimeException(
"Lambda expression in calls to JuliaTopographyFractal() must be of one variable.",
this);
131 fDef = this.Arguments[i - 1];
133 else if (Obj is Complex z2)
154 ColorExpression = this.Arguments[i].SubExpression;
159 Palette = ColorModels.RandomLinearAnalogousHSL.CreatePalette(1024, 16, out
int Seed,
this,
Variables);
160 ColorExpression =
"RandomLinearAnalogousHSL(1024,16," + Seed.ToString() +
")";
162 if (i < c && this.Arguments[i] is
null)
178 throw new ScriptRuntimeException(
"Parameter mismatch in call to JuliaTopographyFractal(z,c|f,dr[,Palette][,dimx[,dimy]]).",
182 if (dimx <= 0 || dimx > 5000 || dimy <= 0 || dimy > 5000)
188 this.FractalZoomScript,
new object[] { Palette, dimx, dimy, r0, i0, ColorExpression, fDef });
192 return CalcJulia(
Variables, rc, ic, r0, i0, dr, Palette, dimx, dimy,
this,
193 this.FractalZoomScript,
new object[] { Palette, dimx, dimy, r0, i0, ColorExpression, fDef });
197 private string FractalZoomScript(
double r,
double i,
double Size,
object State)
199 object[] Parameters = (
object[])State;
200 int DimX = (int)Parameters[1];
201 int DimY = (int)Parameters[2];
202 double r0 = (double)Parameters[3];
203 double i0 = (double)Parameters[4];
204 string ColorExpression = (string)Parameters[5];
207 StringBuilder sb =
new StringBuilder();
209 sb.Append(
"JuliaTopographyFractal((");
229 if (!
string.IsNullOrEmpty(ColorExpression))
232 sb.Append(ColorExpression);
236 sb.Append(DimX.ToString());
238 sb.Append(DimY.ToString());
241 return sb.ToString();
248 SKColor[] Palette,
int Width,
int Height,
ScriptNode Node, FractalZoomScript FractalZoomScript,
object State)
250 double r0, i0, r1, i1;
253 double zr, zi, zrt, zr2, zi2;
262 r0 = rCenter - rDelta;
263 r1 = rCenter + rDelta;
265 aspect = ((double)Width) / Height;
267 i0 = iCenter - rDelta / aspect;
268 i1 = iCenter + rDelta / aspect;
270 dr = (r1 - r0) / Width;
271 di = (i1 - i0) / Height;
273 int Size = Width * Height;
274 int[] ColorIndex =
new int[Size];
276 for (y = 0, i = i0, index = 0; y < Height; y++, i += di)
278 for (x = 0, r = r0; x < Width; x++, r += dr)
287 while (zr2 + zi2 < 9 && n < N)
290 zrt = zr2 - zi2 + R0;
291 zi = 2 * zr * zi + I0;
299 ColorIndex[index++]=N;
301 ColorIndex[index++]=n;
316 FractalZoomScript FractalZoomScript,
object State)
318 double r0, i0, r1, i1;
328 r0 = rCenter - rDelta;
329 r1 = rCenter + rDelta;
331 aspect = ((double)Width) / Height;
333 i0 = iCenter - rDelta / aspect;
334 i1 = iCenter + rDelta / aspect;
336 dr = (r1 - r0) / Width;
337 di = (i1 - i0) / Height;
339 int Size = Width * Height;
340 int[] ColorIndex =
new int[Size];
347 for (y = 0, i = i0; y < Height; y++, i += di)
349 Complex[] Row =
new Complex[Width];
350 int[] Offset =
new int[Width];
353 for (x = 0, x2 = y * Width, r = r0; x < Width; x++, r += dr, x2++)
355 Row[x] =
new Complex(r, i);
363 while (n < N && c > 0)
368 Row = Obj.AssociatedObjectValue as Complex[];
373 "and return complex vectors of equal length. Type returned: " +
374 Obj.GetType().FullName, Node);
376 else if (Row.Length != c)
379 "and return complex vectors of equal length. Length returned: " +
380 Row.Length.ToString() +
". Expected: " + c.ToString(), Node);
383 for (x = x2 = 0; x < c; x++)
406 Array.Resize(ref Row, x2);
407 Array.Resize(ref Offset, x2);
414 for (x = 0; x < c; x++)
424 return new FractalGraph(
Variables,
FractalGraph.
ToPixels(Boundary, Width, Height, Palette), r0, i0, r1, i1, rDelta * 2,
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
JuliaTopographyFractal(ScriptNode z, ScriptNode c, ScriptNode dr, ScriptNode Palette, ScriptNode DimX, int Start, int Length, Expression Expression)
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
JuliaTopographyFractal(ScriptNode z, ScriptNode c, ScriptNode dr, ScriptNode Palette, int Start, int Length, Expression Expression)
TODO
override string[] DefaultArgumentNames
TODO
JuliaTopographyFractal(ScriptNode z, ScriptNode c, ScriptNode dr, int Start, int Length, Expression Expression)
TODO
JuliaTopographyFractal(ScriptNode z, ScriptNode c, ScriptNode dr, ScriptNode Palette, ScriptNode DimX, ScriptNode DimY, int Start, int Length, Expression Expression)
TODO
static FractalGraph CalcJulia(double rCenter, double iCenter, ILambdaExpression f, double rDelta, Variables Variables, SKColor[] Palette, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State)
TODO
override IElement Evaluate(IElement[] Arguments, Variables Variables)
TODO
override string FunctionName
TODO
Defines a clickable fractal graph in the complex plane.
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
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.